@@ -92,26 +92,36 @@ jobs:
9292 PRIVATE_KEY : ${{ secrets.SSH_PRIVATE_KEY }}
9393 run : |
9494 set -euo pipefail
95-
95+
96+ # SSH Key Setup (Necessary for this step)
9697 mkdir -p ~/.ssh
97- # Add private key safely, ensuring a terminating newline
9898 printf '%s\n' "$PRIVATE_KEY" > ~/.ssh/deploy_key
9999 chmod 600 ~/.ssh/deploy_key
100100 ssh-keyscan -H $HOST >> ~/.ssh/known_hosts
101-
102- ssh -i ~/.ssh/deploy_key $USER@$HOST << 'ENDSSH'
103- set -euo pipefail
104-
105- timeout=60
106- while [ $timeout -gt 0 ]; do
107- if sudo ls /opt/tomcat/webapps/ | grep -q "clippr"; then
108- echo "✅ Application deployed successfully!"
109- exit 0
110- fi
111- echo "Waiting for deployment... ($timeout seconds remaining)"
112- sleep 5
113- timeout=$((timeout - 5))
114- done
115- echo "❌ Deployment verification failed"
116- exit 1
101+
102+ # 🔑 Run verification and check its exit code
103+ if ssh -i ~/.ssh/deploy_key $USER@$HOST << 'ENDSSH'
104+ set -euo pipefail
105+
106+ timeout=60
107+ while [ $timeout -gt 0 ]; do
108+ # Check for the presence of the exploded 'clippr' directory
109+ if sudo ls /opt/tomcat/webapps/ | grep -q "clippr"; then
110+ echo "✅ Application deployed successfully on server."
111+ exit 0 # Success exit on server
112+ fi
113+ echo "Waiting for deployment... ($timeout seconds remaining)"
114+ sleep 5
115+ timeout=$((timeout - 5))
116+ done
117+
118+ # If the loop finishes without finding the directory, exit with 1
119+ echo "❌ Deployment verification failed on server."
120+ exit 1 # Failure exit on server
117121 ENDSSH
122+ then
123+ echo "Verification Step PASSED."
124+ else
125+ echo "Verification Step FAILED."
126+ exit 1 # Fail the job if verification fails
127+ fi
0 commit comments