Sifa professional network frontend (Next.js, React, TailwindCSS)
sifa.id/
1name: Deploy
2on:
3 push:
4 branches: [main]
5 workflow_dispatch:
6
7jobs:
8 deploy:
9 runs-on: ubuntu-latest
10 permissions:
11 contents: read
12 packages: write
13
14 steps:
15 - uses: actions/checkout@v4
16
17 - name: Log in to GHCR
18 uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
19 with:
20 registry: ghcr.io
21 username: ${{ github.actor }}
22 password: ${{ secrets.GITHUB_TOKEN }}
23
24 - name: Build and push Docker image
25 uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
26 with:
27 context: .
28 push: true
29 no-cache: true
30 tags: ghcr.io/singi-labs/sifa-web:latest,ghcr.io/singi-labs/sifa-web:${{ github.sha }}
31
32 - name: Deploy to VPS
33 if: env.VPS_HOST != ''
34 env:
35 VPS_HOST: ${{ secrets.VPS_HOST }}
36 uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1
37 with:
38 host: ${{ secrets.VPS_HOST }}
39 username: ${{ secrets.VPS_USER }}
40 key: ${{ secrets.VPS_SSH_KEY }}
41 script: |
42 cd /opt/sifa
43 docker compose pull sifa-web
44 docker compose up -d --force-recreate --no-deps sifa-web
45 docker image prune -af
46
47 - name: Verify deployment health
48 if: env.VPS_HOST != ''
49 env:
50 VPS_HOST: ${{ secrets.VPS_HOST }}
51 uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1
52 with:
53 host: ${{ secrets.VPS_HOST }}
54 username: ${{ secrets.VPS_USER }}
55 key: ${{ secrets.VPS_SSH_KEY }}
56 script: |
57 # Wait for web container to be reachable
58 for i in $(seq 1 10); do
59 status=$(curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/ 2>/dev/null || echo "000")
60 if [ "$status" = "200" ]; then
61 echo "Web healthy after $((i * 3))s"
62 break
63 fi
64 echo "Waiting for web... (attempt $i, status: $status)"
65 sleep 3
66 done
67 if [ "$status" != "200" ]; then
68 echo "FATAL: Web did not become healthy within 30s"
69 exit 1
70 fi
71 # Verify API is reachable from web's perspective
72 api_status=$(curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:3100/api/health/ready 2>/dev/null || echo "000")
73 if [ "$api_status" != "200" ]; then
74 echo "WARNING: API readiness check failed (status: $api_status)"
75 exit 1
76 fi
77 echo "API readiness confirmed"
78 # Warm ISR cache for heavy pages
79 curl -sf -o /dev/null http://127.0.0.1:3000/events/atmosphereconf-2026 || true