add gateway automatic template and fefan vm
This commit is contained in:
23
modules/apps/gateway/lib/scripts/pull-webhook.py
Normal file
23
modules/apps/gateway/lib/scripts/pull-webhook.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from flask import Flask, request, abort
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
SECRET = os.environ.get("WEBHOOK_SECRET")
|
||||
REPOSITORY = os.environ.get("GATEWAY_REPOSITORY_LOCATION")
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/reload", methods=["POST"])
|
||||
def reload():
|
||||
token = request.headers.get("X-Webhook-Token")
|
||||
if token != SECRET:
|
||||
abort(403)
|
||||
|
||||
subprocess.run(
|
||||
["git", "-C", REPOSITORY, "pull"],
|
||||
check=True
|
||||
)
|
||||
return "ok\n"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
Reference in New Issue
Block a user