release 0.1 #1

Merged
vanzhiganov merged 3 commits from develop/0.1 into main 2025-01-25 19:51:40 +00:00
5 changed files with 26 additions and 7 deletions
Showing only changes of commit e6ab985c12 - Show all commits

View file

@ -11,11 +11,11 @@ pip install -r requirements.txt
### rpm
```shell
dnf install python3-flask
dnf install python3-flask python3-mod_wsgi
```
## run
```shell
python3 koji-forgejo-webook.py
```
```

5
config.ini Normal file
View file

@ -0,0 +1,5 @@
[DEFAULT]
SECRET_KEY = $3cr3tk3y
KOJI_SERVER = https://kojidev.stackwebservices.org/kojihub
KOJI_TARGET = rl9-candidate
WEBHOOK_SECRET_KEY = your_secret_key

View file

@ -0,0 +1,5 @@
WSGIDaemonProcess forgejo processes=2 threads=4
WSGIScriptAlias /forgejo-webhook /opt/koji-forgejo-webhook/koji_forgejo_webhook.wsgi
<Directory /opt/koji-forgejo-webhook>
Require all granted
</Directory>

View file

@ -2,17 +2,17 @@ import json
import hashlib
import hmac
import logging
import configparser
from flask import Flask, request, abort
import koji
# Load configuration from .ini file
config = configparser.ConfigParser()
config.read('config.ini')
app = Flask(__name__)
app.config['SECRET_KEY'] = '123'
# koji
app.config['KOJI_SERVER'] = 'https://kojidev.stackwebservices.org/kojihub'
app.config['KOJI_TARGET'] = 'rl9-candidate'
app.config.from_mapping(config['DEFAULT'])
app.config['WEBHOOK_SECRET_KEY'] = 'your_secret_key'
class KojiProcessor:
def __init__(self):
@ -98,6 +98,7 @@ class ForgejoWebhookProcessor:
abort(400)
@app.route('/', methods=['POST'])
@app.route('/forgejo-webhook', methods=['POST'])
def webhook():
processor = ForgejoWebhookProcessor(app.config['WEBHOOK_SECRET_KEY'])
@ -115,6 +116,7 @@ def webhook():
return 'Webhook processed', 200
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
app.run(host="0.0.0.0", port=5001)

View file

@ -0,0 +1,7 @@
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, "/opt/koji-forgejo-webhook")
from koji_forgejo_webhook import app as application