Created
April 13, 2017 14:41
-
-
Save AlexR1712/9a22e8032d1c75ac746be254c222ae80 to your computer and use it in GitHub Desktop.
Webhook Flask Gitlab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git pull | |
cd laradock | |
docker-compose down | |
docker-compose up -d nginx mysql phpmyadmin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from flask import Flask | |
from flask import request | |
from flask import jsonify | |
TOKEN="SECRET_TOKEN_GITLAB" | |
app = Flask(__name__) | |
@app.route('/', methods=['GET', 'POST']) | |
def index(): | |
if request.headers.get('X-Gitlab-Token') != None: | |
if request.headers.get('X-Gitlab-Token') == TOKEN: | |
subprocess.call("./script.sh") | |
return jsonify({"ok":True, "message": "Success"}) | |
else: | |
return jsonify({"ok":False, "message": "Fail"}) | |
else: | |
return jsonify({"ok":False, "message": "Not Gitlab Token Provided"}) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment