Skip to content

Commit

Permalink
Update django_CI.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
2ming00 authored Aug 31, 2024
1 parent 6171481 commit 158cb98
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/django_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Upload Code to EC2

- name: Upload and Deploy Code to EC2
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USER: ubuntu
EC2_KEY: ${{ secrets.EC2_KEY }}
run: |
echo "${{ secrets.EC2_KEY }}" > key.pem
chmod 400 key.pem
scp -o StrictHostKeyChecking=no -i key.pem -r ./aiServer ubuntu@$EC2_HOST:/home/ubuntu/
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no -i key.pem -t ubuntu@$EC2_HOST << 'EOF'
cd /home/ubuntu/aiServer
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install django djangorestframework drf-yasg
nohup gunicorn --bind 0.0.0.0:8000 aiServer.wsgi:application &
sudo service nginx restart
# 코드 업로드
scp -o StrictHostKeyChecking=no -i key.pem -r ./aiServer $EC2_USER@$EC2_HOST:/home/ubuntu/
# 서버에 접속하여 작업 수행
ssh -o StrictHostKeyChecking=no -i key.pem $EC2_USER@$EC2_HOST << 'EOF'
cd /home/ubuntu/aiServer || exit 1
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install django djangorestframework drf-yasg
nohup gunicorn --bind 0.0.0.0:8000 aiServer.wsgi:application &
sudo service nginx restart
EOF
# 사용된 키 삭제
rm key.pem

0 comments on commit 158cb98

Please sign in to comment.