Skip to content

Commit

Permalink
Update aws-deployment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
AdleeAfif authored Apr 16, 2024
1 parent 7f7b89f commit 6e63020
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/aws-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ jobs:

# Start the application with pm2
pm2 start npm --name "portfolio-app" -- start

# Deploy the application to EC2
echo "${{ secrets.EC2_KEY_PAIR }}" | scp -i - -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r portfolio-app/. ${{ env.EC2_USERNAME }}@${{ env.EC2_PUBLIC_IP }}:${{ env.DEPLOY_PATH }}
echo "${{ secrets.EC2_KEY_PAIR }}" > ec2_key.pem
chmod 600 ec2_key.pem
scp -i ec2_key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r portfolio-app/. ${{ env.EC2_USERNAME }}@${{ env.EC2_PUBLIC_IP }}:${{ env.DEPLOY_PATH }}

# Restart the application on EC2 using pm2
echo "${{ secrets.EC2_KEY_PAIR }}" | ssh -i - -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ env.EC2_USERNAME }}@${{ env.EC2_PUBLIC_IP }} "cd ${{ env.DEPLOY_PATH }} && pm2 restart portfolio-app"
ssh -i ec2_key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ env.EC2_USERNAME }}@${{ env.EC2_PUBLIC_IP }} "cd ${{ env.DEPLOY_PATH }} && pm2 restart portfolio-app"

# Cleanup
rm ec2_key.pem

0 comments on commit 6e63020

Please sign in to comment.