1
0
Fork 0

Misc fixes

This commit is contained in:
Alexandre Aubin 2021-05-21 20:12:00 +02:00
parent 4b2e630429
commit 249307a849
6 changed files with 19 additions and 11 deletions

View file

@ -23,7 +23,7 @@ Configure the webhook on github
Also need to allow the bot to push on all repos
Configure nginx to reverse proxy on port 80123 (or whichever port you set in the systemd config)
Configure nginx to reverse proxy on port 8123 (or whichever port you set in the systemd config)
```bash
echo "github_webhook_secret" > github_webhook_secret

View file

@ -12,15 +12,19 @@ def generate_READMEs(app_path):
if not os.path.exists(app_path):
raise Exception("App path provided doesn't exists ?!")
manifest = json.load(open(os.path.join(app_path, "manifest.json")))
upstream = manifest.get("upstream", {})
if not upstream and not os.path.exists(os.path.join(app_path, "doc", "DISCLAIMER.md")):
print("There's no 'upstream' key in the manifest, and doc/DISCLAIMER.md doesn't exists - therefore assuming that we shall not auto-update the README.md for this app yet.")
return
env = Environment(loader=FileSystemLoader('./templates'))
for lang, lang_suffix in [("en", ""), ("fr", "_fr")]:
template = env.get_template(f'README{lang_suffix}.md.j2')
manifest = json.load(open(os.path.join(app_path, "manifest.json")))
upstream = manifest.get("upstream", {})
if os.path.exists(os.path.join(app_path, "doc", "screenshots")):
screenshots = os.listdir(os.path.join(app_path, "doc", "screenshots"))
if ".gitkeep" in screenshots:

View file

@ -7,7 +7,7 @@ location / {
client_max_body_size 100M;
proxy_pass http://127.0.0.1:80123;
proxy_pass http://127.0.0.1:8123;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";

View file

@ -1,3 +1,4 @@
argparse
jinja2
github-webhook==1.0.4
gunicorn==20.1.0

View file

@ -10,11 +10,12 @@ webhook = Webhook(app) # Defines '/postreceive' endpoint
webhook.secret = open("github_webhook_secret", "r").read().strip()
login = open("login").read().strip()
token = open("token").read().strip()
my_env = os.environ.copy()
my_env["GIT_TERMINAL_PROMPT"] = "0"
login = open("login").read().strip()
token = open("token").read().strip()
def git(cmd, in_folder=None):
@ -38,16 +39,18 @@ def on_push(data):
branch = data["ref"].split("/", 2)[2]
folder = subprocess.check_output(["mktemp", "-d"])
git(f"clone https://{login}:{token}@github.com/{repository} --single-branch --branch {branch} {folder}")
git(["clone", f"https://{login}:{token}@github.com/{repository}", "--single-branch", "--branch", branch, folder])
generate_READMEs(folder)
git(["add", "README*.md"], in_folder=folder)
diff_not_empty = bool(subprocess.check_output(f"cd {folder} && git diff HEAD --compact-summary", shell=True).strip().decode("utf-8"))
if not diff_not_empty:
return
git(["commit", "-a", "-m", "Auto-update README", "--author='Yunohost-Bot <>'"], in_folder=folder)
git(f"push fork origin {branch} --quiet", in_folder=folder)
git(["push", "fork", "origin", branch, "--quiet"], in_folder=folder)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80123)
app.run(host="0.0.0.0", port=8123)

View file

@ -7,7 +7,7 @@ PIDFile=/run/gunicorn/autoreadme_webhook-pid
User=autoreadme_webhook
Group=autoreadme_webhook
WorkingDirectory=__PATH_TO_README_GENERATOR__
ExecStart=__PATH_TO_README_GENERATOR__/venv/bin/gunicorn -w 4 -b 127.0.0.1:80123 webhook:app
ExecStart=__PATH_TO_README_GENERATOR__/venv/bin/gunicorn -w 4 -b 127.0.0.1:8123 webhook:app
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true