-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
name: dev branch auto ci process script | ||
name: Deploy to Development | ||
|
||
on: # 아래 job을 실행시킬 상황 | ||
on: | ||
push: | ||
branches: [dev] | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
deploy: | ||
name: deploy | ||
runs-on: ubuntu-latest # 실행될 인스턴스 OS와 버전 | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: excuting remote ssh commands | ||
uses: appleboy/ssh-action@v0.1.6 # ssh 접속하는 오픈소스 | ||
with: | ||
host: ${{ secrets.REMOTE_IP_DEV }} # 인스턴스 IP | ||
username: ${{ secrets.REMOTE_USER_DEV }} # 우분투 아이디 | ||
key: ${{ secrets.REMOTE_PRIVATE_KEY_DEV }} # ec2 instance pem key | ||
port: ${{ secrets.REMOTE_SSH_PORT_DEV }} # 접속포트 | ||
passphrase: ${{ secrets.REMOTE_PASSPHRASE_DEV }} | ||
script: | # 실행할 스크립트 | ||
cd otlplus-nest-server | ||
git pull origin dev | ||
sudo docker stop otlplus-server-nest-dev | ||
sudo docker rm otlplus-server-nest-dev | ||
sudo docker rmi otlplus-server-nest-dev | ||
sudo ./deploy.sh -e dev | ||
- name: Send Deployment Webhook | ||
env: | ||
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} | ||
run: | | ||
curl -X POST \ | ||
-H "X-Hub-Signature-256: sha256=$(echo -n '{}' | openssl dgst -sha256 -hmac $WEBHOOK_SECRET)" \ | ||
http://webhook.otl.dev.sparcs.org/server-webhook |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
# | ||
/env/* | ||
.venv | ||
|
||
# Logs | ||
logs | ||
|
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/python3 | ||
|
||
from flask import * | ||
from werkzeug.middleware.proxy_fix import ProxyFix | ||
import os | ||
from dotenv import load_dotenv | ||
import hmac | ||
import hashlib | ||
|
||
FLASK_ENV = os.getenv("FLASK_ENV", "development") | ||
load_dotenv(f".env.{FLASK_ENV}") | ||
|
||
app = Flask(__name__) | ||
|
||
app.wsgi_app = ProxyFix( | ||
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1 | ||
) | ||
|
||
@app.route('/server-webhook', methods=["POST"]) | ||
def otlplus_redeploy(): | ||
webhook_secret = os.getenv("WEBHOOK_SECRET").encode() | ||
signature = 'sha256=' + hmac.new(webhook_secret, request.data, hashlib.sha256).hexdigest() | ||
if 'X-Hub-Signature-256' not in request.headers or not hmac.compare_digest( | ||
signature, request.headers['X-Hub-Signature-256'] | ||
): | ||
abort(403) | ||
|
||
os.spawnl(os.P_NOWAIT, "/bin/bash", "/bin/bash", "/home/otlplus/server/deploy.sh -e dev") | ||
return "Done", 200 | ||
|
||
@app.route('/server-webhook-status', methods=["GET"]) | ||
def clubs_stage_redeploy(): | ||
# os.spawnl(os.P_NOWAIT, "/bin/bash", "/bin/bash", "/home/otlplus/server/deploy.sh -e dev") | ||
return "Done", 200 | ||
|
||
if __name__ == '__main__': | ||
app.run(host="127.0.0.1", threaded=True, port=5000) |
This file contains 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
This file contains 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