Skip to content

Deploy Production

Deploy Production #14

Workflow file for this run

name: Deploy Production
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
set -e
cd ~/Hs_codes_api
echo "Pulling latest code..."
git fetch origin main
git reset --hard origin/main
echo "Building and starting containers..."
docker compose up -d --build
echo "Waiting for application to start..."
sleep 20
echo "Checking health endpoint..."
for i in $(seq 1 20); do
if curl -fsS http://localhost:8001/api/v1/health/ > /dev/null; then
echo "Health check passed"
exit 0
fi
echo "Attempt $i/20 - waiting..."
sleep 5
done
echo "Health check failed after 100s"
exit 1