diff --git a/.github/workflows/ssh.yml b/.github/workflows/ssh.yml new file mode 100644 index 0000000..b5c042d --- /dev/null +++ b/.github/workflows/ssh.yml @@ -0,0 +1,51 @@ +name: SSH Connection Test + +on: + push: + branches: + - dev + +jobs: + test-ssh: + runs-on: ubuntu-latest + + steps: + - name: SSH into VM and run deployment + run: | + echo "${{ secrets.KEY }}" > key.pem + chmod 600 key.pem + + ssh -tt -o ServerAliveInterval=60 -o ServerAliveCountMax=5 \ + -i key.pem -o StrictHostKeyChecking=no -o IdentitiesOnly=yes \ + ubuntu@195.15.196.113 << 'EOF' + + echo "✅ Logged into VM successfully" + whoami + + echo "📂 Listing contents of home directory:" + ls ~ + + echo "========== Deployment Started: \$(date) ==========" + echo "Processing TapgoUI-Kiosk..." + + cd ~/TapgoUI-Kiosk || { echo "[ERROR] Directory TapgoUI-Kiosk not found"; exit 1; } + + echo "[INFO] Listing files in TapgoUI-Kiosk directory..." + ls -la + + echo "[INFO] Pulling latest changes from dev branch..." + sudo git pull origin dev || { echo "[ERROR] Git pull failed"; exit 1; } + + echo "[INFO] Installing dependencies..." + sudo npm install --legacy-peer-deps || { echo "[ERROR] npm install failed"; exit 1; } + + echo "[INFO] Building the Angular app..." + sudo npm run build || { echo "[ERROR] Build failed"; exit 1; } + + + echo "[✅ SUCCESS] Deployment completed at \$(date)" + echo "===============================================" + + echo "[✅ FINISHED] Closing SSH connection." + exit 0 + EOF