|
| 1 | +from django import conf |
1 | 2 | from flask import Flask, jsonify, request |
2 | 3 | import os, yaml, requests, time |
3 | 4 |
|
@@ -31,17 +32,18 @@ def SlackAlert(msg): |
31 | 32 | def webhook(): |
32 | 33 | payload = request.get_json() |
33 | 34 | branch = payload['ref'].split('/')[-1] |
34 | | - ## parse github webhook payload response and get event type and branch name |
35 | | - SlackAlert("👀 A new commit has been detected to the {} branch, working on updating source code.".format(branch)) |
36 | | - os.system('cd ' + PROJECT_PATH + ' && git pull origin ' + branch) |
37 | | - SlackAlert("🎉 The {} branch has been updated successfully.".format(branch)) |
38 | | - SlackAlert("🛠 Executing the build script.") |
39 | | - ExecuteBashScript('build.sh', branch) |
40 | | - SlackAlert("🎉 The build script has been executed successfully.") |
41 | | - SlackAlert("🛠 Executing the deploy script.") |
42 | | - ExecuteBashScript('deploy.sh', branch) |
43 | | - SlackAlert("🎉 The deploy script has been executed successfully.") |
44 | | - return jsonify(payload) |
| 35 | + if branch == config['BRANCH_TO_USE']: |
| 36 | + ## parse github webhook payload response and get event type and branch name |
| 37 | + SlackAlert("👀 A new commit has been detected to the {} branch, working on updating source code.".format(branch)) |
| 38 | + os.system('cd ' + PROJECT_PATH + ' && git pull origin ' + branch) |
| 39 | + SlackAlert("🎉 The {} branch has been updated successfully.".format(branch)) |
| 40 | + SlackAlert("🛠 Executing the build script.") |
| 41 | + ExecuteBashScript('build.sh', branch) |
| 42 | + SlackAlert("🎉 The build script has been executed successfully.") |
| 43 | + SlackAlert("🛠 Executing the deploy script.") |
| 44 | + ExecuteBashScript('deploy.sh', branch) |
| 45 | + SlackAlert("🎉 The deploy script has been executed successfully.") |
| 46 | + return jsonify(payload) |
45 | 47 |
|
46 | 48 |
|
47 | 49 | if __name__ == "__main__": |
|
0 commit comments