Skip to content

Commit

Permalink
Update dev-piramal-s3-deployment.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhilashKD authored Nov 27, 2024
1 parent abdf60d commit cac1f5e
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions .github/workflows/dev-piramal-s3-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,30 @@ jobs:
sudo apt-get update
sudo apt-get install -y openssh-client
- name: Deploy application to EC2
env:
PRIVATE_KEY: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
EC2_HOST: ${{ secrets.EC2_HOST_DEV }}
EC2_USER: ${{ secrets.EC2_USER_DEV }}
- name: Debug SSH Setup
run: |
echo "$PRIVATE_KEY" > ec2_key.pem
echo "${{ secrets.EC2_SSH_PRIVATE_KEY }}" > ec2_key.pem
chmod 600 ec2_key.pem
ls -l ec2_key.pem
echo "Host: ${{ secrets.EC2_HOST_DEV }}"
echo "User: ${{ secrets.EC2_USER_DEV }}"
# Clean up remote directory
ssh -i ec2_key.pem $EC2_USER_DEV@$EC2_HOST_DEV << 'EOF'
echo "Removing existing files in the remote directory..."
sudo rm -rf /var/www/dev-uba-issuer.tekdinext.com/public/*
- name: Clean Up Remote Directory and Deploy
env:
PRIVATE_KEY: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
EC2_HOST_DEV: ${{ secrets.EC2_HOST_DEV }}
EC2_USER_DEV: ${{ secrets.EC2_USER_DEV }}
run: |
export SSH_OPTS="-o StrictHostKeyChecking=no"
ssh $SSH_OPTS -i ec2_key.pem $EC2_USER_DEV@$EC2_HOST_DEV << 'EOF'
echo "Removing existing files..."
sudo rm -rf /var/www/dev-uba-issuer.tekdinext.com/public/*
EOF
# Copy the new build
echo "Copying the new build to the remote server..."
scp -i ec2_key.pem -r dist/sunbird-rc-ui/* $EC2_USER_DEV@$EC2_HOST_DEV:/var/www/dev-uba-issuer.tekdinext.com/public
# Set permissions and restart Nginx
ssh -i ec2_key.pem $EC2_USER_DEV@$EC2_HOST_DEV << 'EOF'
echo "Setting permissions on the remote directory..."
sudo chown -R www-data:www-data /var/www/dev-uba-issuer.tekdinext.com
echo "Restarting Nginx..."
sudo systemctl restart nginx
echo "Deployment complete."
echo "Copying files..."
scp $SSH_OPTS -i ec2_key.pem -r dist/sunbird-rc-ui/* $EC2_USER_DEV@$EC2_HOST_DEV:/var/www/dev-uba-issuer.tekdinext.com/public
ssh $SSH_OPTS -i ec2_key.pem $EC2_USER_DEV@$EC2_HOST_DEV << 'EOF'
echo "Setting permissions..."
sudo chown -R www-data:www-data /var/www/dev-uba-issuer.tekdinext.com
echo "Restarting Nginx..."
sudo systemctl restart nginx
EOF
- name: Post job cleanup
run: |
rm -f ec2_key.pem
continue-on-error: true

0 comments on commit cac1f5e

Please sign in to comment.