Skip to content

Commit

Permalink
Merge pull request #1 from Alpha-mon/github-action
Browse files Browse the repository at this point in the history
Add github action
  • Loading branch information
megymj authored Nov 11, 2023
2 parents 729e7bd + e83a631 commit f5b1209
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy and Run Flask in EC2

on:
push:
branches: [ "main" ]

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 AI-RoboAdvisor-Flask
cd AI-RoboAdvisor-Flask
else
cd AI-RoboAdvisor-Flask
git pull origin main
fi
# Use pip3 for Python 3.9
sudo apt-get update
sudo apt install python3-pip -y
sudo pip3 install -r requirements.txt
# Flask 애플리케이션 프로세스를 찾아서 종료합니다.
if pgrep -f 'python3 app.py'; then
echo "Process found. Stopping 'python3 app.py'."
pkill -f 'python3 app.py'
else
echo "Process not found."
fi
# 애플리케이션을 재실행합니다.
nohup python3 app.py > flask_app.log 2>&1 &
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tensorboard==2.14.1
tensorboard-data-server==0.7.2
tensorflow==2.14.0
tensorflow-estimator==2.14.0
tensorflow-intel==2.14.0
#tensorflow-intel==2.14.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.3.0
threadpoolctl==3.2.0
Expand Down

0 comments on commit f5b1209

Please sign in to comment.