From 1dc0e06f85407dbc0df2fb605ce1ecb78ca10c53 Mon Sep 17 00:00:00 2001 From: BURG3R5 <77491630+BURG3R5@users.noreply.github.com> Date: Wed, 4 May 2022 13:26:17 +0530 Subject: [PATCH] docs: Add installation instructions. Signed-off-by: BURG3R5 <77491630+BURG3R5@users.noreply.github.com> --- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++---- bot_manifest.yml | 39 +++++++++++++++++++++++++ main.py | 2 +- 3 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 bot_manifest.yml diff --git a/README.md b/README.md index fdc9528..f0ac65f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![CI](https://github.com/mdg-iitr/github-slack-bot/actions/workflows/ci.yml/badge.svg)](https://github.com/mdg-iitr/github-slack-bot/actions/workflows/ci.yml) -[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) # GitHubBot @@ -16,6 +16,71 @@ This bot has than the official GitHub-Slack integration. +### Installation + +#### 0. Requirements: + +- A server with public endpoints +- Python **3.10.2** or above: [Windows](https://www.python.org/downloads/windows/), [MacOS](https://www.python.org/downloads/macos/), [Linux](https://www.linuxcapable.com/how-to-install-python-3-10-on-ubuntu-20-04/) +- Git + +#### 1. Clone this repo + +``` +$ git clone https://github.com/mdg-iitr/github-slack-bot.git +$ cd github-slack-bot +``` + +#### 2. Connect to GitHub + +- Add `/github/events` to your organization or repository's webhooks. +- Set "Content type" to `application/json` +- Check the "Send me everything" radio button + +#### 3. Connect to Slack + +- Find and replace every instance of `` in the [provided manifest](https://github.com/BURG3R5/github-slack-bot/blob/master/bot_manifest.yml) with whatever your server's URL is. +- Go to [link](https://api.slack.com/apps) and create a new app using the edited manifest. +- Install the app to your Slack workspace. + +#### 4. Environment variables + +- Copy `.env.sample` to `.env`. +- Set `DEBUG` to 0 and the other variables to appropriate values. + +#### 5. Create a virtual environment + +``` +$ python -m venv venv +``` +Or, if your system contains both Python 2 and Python 3, use `python3`. + +#### 6. Activate your virtual environment + +MacOS and Linux: +``` +$ source venv/bin/activate +``` + +Windows: +``` +> venv\Scripts\activate +``` + +#### 7. Install dependencies + +``` +$ pip install -r requirements.txt +``` + +Or, if your system contains both Python 2 and Python 3, use `pip3`. + +#### 8. Run the bot + +``` +$ python main.py +``` + ### Setup for development #### 0. Requirements: @@ -37,10 +102,8 @@ $ python -m venv venv ``` Or, if your system contains both Python 2 and Python 3, use `python3`. - #### 3. Activate your virtual environment - MacOS and Linux: ``` $ source venv/bin/activate @@ -63,16 +126,16 @@ $ pip install pre-commit $ pre-commit install ``` -#### 6. Get the environment variables from another contributor +#### 6. Get the environment variables from a maintainer #### 7. [Download and configure ngrok](https://betterprogramming.pub/ngrok-make-your-localhost-accessible-to-anyone-333b99e44b07) -#### 8. Send your generated URL to MDG org admins +#### 8. Send your generated URL to a maintainer #### 9. Run the bot ``` $ python main.py ``` -## Contributors ✨ +### Contributors ✨ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): diff --git a/bot_manifest.yml b/bot_manifest.yml new file mode 100644 index 0000000..a071014 --- /dev/null +++ b/bot_manifest.yml @@ -0,0 +1,39 @@ +display_information: + name: GitHubBot + description: Concisely and precisely informs users of events on GitHub. + background_color: "#000000" + long_description: Concisely and precisely informs users of events on GitHub. Subscribe to any number of events using the `/subscribe` command. Get more usage instructions using the `/help` command. Source code at https://github.com/BURG3R5/github-slack-bot +features: + bot_user: + display_name: GitHubBot + always_online: true + slash_commands: + - command: /subscribe + url: /slack/commands + description: Subscribe to events in a GitHub repository + usage_hint: repository event1 [event2, event3, ...] + should_escape: false + - command: /unsubscribe + url: /slack/commands + description: Unsubscribe from events in a GitHub repository + usage_hint: repository event1 [event2, event3, ...] + should_escape: false + - command: /help + url: /slack/commands + description: Prints instructions and keywords. + should_escape: false + - command: /list + url: /slack/commands + description: Lists subscriptions for the current channel. + should_escape: false +oauth_config: + scopes: + bot: + - chat:write + - chat:write.customize + - commands + - files:write +settings: + org_deploy_enabled: false + socket_mode_enabled: false + token_rotation_enabled: false diff --git a/main.py b/main.py index 7555d99..2bfc2ba 100644 --- a/main.py +++ b/main.py @@ -93,4 +93,4 @@ def manage_slack_commands() -> dict | None: ) bot: SlackBot = SlackBot(token=os.environ["SLACK_OAUTH_TOKEN"]) - run(host="", port=5556, debug=True) + run(host="", port=5556, debug=debug)