From baec164052a73fe68fd5be9f97e72020d59ddd6e Mon Sep 17 00:00:00 2001 From: Rubayet Date: Sun, 20 Oct 2024 13:50:02 -0700 Subject: [PATCH] Fix SCP transfer and deployment step --- .github/workflows/deploy.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2e81713..a61142b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 && @@ -50,3 +58,4 @@ jobs: echo 'ALPHA_VANTAGE_API_KEY=$ALPHA_VANTAGE_API_KEY' >> .env && docker-compose up -d --build " +