From bdfc0135ebd22d3978196ac55c92bb1eedb8a9f7 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 20 Apr 2021 22:54:09 +0530 Subject: [PATCH] Add Heroku support (#1) * Create Procfile * Create config.py * Create runtime.txt * Create app.json * Add "Deploy to Heroku" button to README.md Co-authored-by: Dash Eclipse --- Procfile | 1 + README.md | 4 ++++ app.json | 20 ++++++++++++++++++++ config.py | 3 ++- runtime.txt | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Procfile create mode 100644 app.json create mode 100644 runtime.txt diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..629b83a --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python main.py diff --git a/README.md b/README.md index 523ca13..3b32d99 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ conflicts. 3. Format and send the text to a Telegram chat through "sendMessage" method of Telegram Bot API (`GET` request) +### Heroku + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/dashezup/github-webhook-to-telegram) + ### Setup You need a Telegram bot token, create a Telegram bot with diff --git a/app.json b/app.json new file mode 100644 index 0000000..ab0af3a --- /dev/null +++ b/app.json @@ -0,0 +1,20 @@ +{ + "name": "GitHub Webhook to Telegram", + "description": "Receive GitHub webhook events and send to Telegram chats with AIOHTTP through Telegram Bot API", + "repository": "https://github.com/dashezup/github-webhook-to-telegram", + "keywords": [ + "github", + "webhooks", + "telegram", + "aiohttp", + "python", + "telegram-bot", + "telegram-bot-api" + ], + "env": { + "HOOK_CONFIG": { + "description": "configuration in JSON format, check README and config_sample.json", + "required": true + } + } +} diff --git a/config.py b/config.py index b28175f..1ed6153 100644 --- a/config.py +++ b/config.py @@ -3,10 +3,11 @@ from os import environ if environ.get('DYNO'): data = json.loads(environ.get("HOOK_CONFIG")) + PORT = int(environ.get('PORT')) else: with open("config.json") as f: data = json.load(f) + PORT = data.get('port') BOT_TOKEN = data['bot_token'] -PORT = data.get('port') GH_WEBHOOKS = data['gh_webhooks'] diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..8766529 --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.9.4