diff --git a/.github/workflows/dev-piramal-s3-deployment.yaml b/.github/workflows/dev-piramal-s3-deployment.yaml index 9ce48a8..fe46eaa 100644 --- a/.github/workflows/dev-piramal-s3-deployment.yaml +++ b/.github/workflows/dev-piramal-s3-deployment.yaml @@ -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