-
Notifications
You must be signed in to change notification settings - Fork 1
43 lines (35 loc) · 1.22 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Deploy Flask in EC2
on:
push:
branches: [ "deploy-test" ]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: connect EC2 instance and deploy docker images to main server
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.AWS_EC2_HOST_IP }}
username: ${{ secrets.AWS_EC2_USERNAME }}
key: ${{ secrets.AWS_SSH_KEY }}
script: |
# 경로 변수 설정
APP_DIR=/home/ubuntu/AI-RoboAdvisor-Flask
REPO_URL=https://github.com/Alpha-mon/AI-RoboAdvisor-Flask.git
# 만약 APP_DIR이 없다면 생성하고 저장소를 clone
if [ ! -d "$APP_DIR" ]; then
git clone $REPO_URL
cd $APP_DIR
git checkout deploy-test
else
cd $APP_DIR
git pull origin main
git checkout deploy-test
fi
sudo pip install -r requirements.txt
# Flask 애플리케이션 프로세스를 찾아서 종료합니다.
pkill -f 'app.py'
# 애플리케이션을 재실행합니다.
nohup python app.py > flask_app.log 2>&1 &