Skip to content

Commit

Permalink
Fix SCP transfer and deployment step
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubayet19 committed Oct 20, 2024
1 parent b10d18a commit baec164
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ jobs:
DB_PORT: ${{ secrets.DB_PORT }}
ALPHA_VANTAGE_API_KEY: ${{ secrets.ALPHA_VANTAGE_API_KEY }}
run: |
scp -o StrictHostKeyChecking=no -i ec2_key.pem -r . ec2-user@${{ secrets.EC2_HOST }}:~/django_project/
# Create a compressed archive of the project files
tar -czf django_project.tar.gz *
# Copy the archive to the EC2 instance
scp -o StrictHostKeyChecking=no -i ec2_key.pem django_project.tar.gz ec2-user@${{ secrets.EC2_HOST }}:~

# SSH into EC2, extract files, set up environment, and run Docker Compose
ssh -o StrictHostKeyChecking=no -i ec2_key.pem ec2-user@${{ secrets.EC2_HOST }} "
mkdir -p ~/django_project &&
tar -xzf ~/django_project.tar.gz -C ~/django_project &&
cd ~/django_project &&
echo 'DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY' >> .env &&
echo 'DB_NAME=$DB_NAME' >> .env &&
Expand All @@ -50,3 +58,4 @@ jobs:
echo 'ALPHA_VANTAGE_API_KEY=$ALPHA_VANTAGE_API_KEY' >> .env &&
docker-compose up -d --build
"

0 comments on commit baec164

Please sign in to comment.