Skip to content

action 코드 리팩토링 #12

action 코드 리팩토링

action 코드 리팩토링 #12

Workflow file for this run

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/[email protected]
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 AI-RoboAdvisor-Flask
cd AI-RoboAdvisor-Flask
else
cd AI-RoboAdvisor-Flask
git pull origin main
fi
# Checkout the deploy-test branch
git checkout deploy-test
# Use pip3 for Python 3.x
sudo pip3 install -r requirements.txt
# Flask 애플리케이션 프로세스를 찾아서 종료합니다.
pkill -f 'python3 app.py'
# 애플리케이션을 재실행합니다.
nohup python3 app.py > flask_app.log 2>&1 &