Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizCampedelli authored Sep 6, 2024
1 parent ed4b72b commit 50b5416
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
deploy-to-ec2:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- name: Checkout Code
Expand Down Expand Up @@ -35,9 +35,14 @@ jobs:
AWS_REGION: 'us-east-1'
run: |
ssh -i /tmp/ec2-key.pem -o StrictHostKeyChecking=no ec2-user@${{ secrets.EC2_IP }} << EOF
# Create the /home/ec2-user/app directory if it doesn't exist
mkdir -p /home/ec2-user/app
cd /home/ec2-user/app
# Pull the latest code
# Install git if not already installed
sudo yum install -y git || sudo apt-get install -y git
# Pull the latest code from the repository
git pull origin main
# Ensure virtual environment exists, create if not
Expand All @@ -50,7 +55,11 @@ jobs:
# Install requirements
pip install --upgrade pip
pip install -r requirements.txt
if [ -f requirements.txt ]; then
pip install -r requirements.txt
else
echo "requirements.txt file not found!"
fi
# Stop any existing Gunicorn process on port 5000
sudo fuser -k 5000/tcp || true
Expand Down

0 comments on commit 50b5416

Please sign in to comment.