a67fdba170
Deploy to Dev / Deploy & Smoke Test (push) Successful in 26s
- fetch+reset instead of pull (survives working-tree drift on CT111) - create api/.env from example and the external web network if missing - health check now retries for 120s and fails the run properly Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
name: Deploy to Production
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch: # Allow manual trigger
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: self-hosted
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Pull latest changes
|
|
run: |
|
|
cd /opt/lisilou-portfolio
|
|
git fetch origin main
|
|
git reset --hard origin/main
|
|
|
|
- name: Build and restart containers
|
|
run: |
|
|
cd /opt/lisilou-portfolio
|
|
# First-run prerequisites for the two-service stack:
|
|
# compose requires api/.env to exist and the external "web" network
|
|
if [ ! -f api/.env ]; then cp api/.env.example api/.env; fi
|
|
docker network inspect web >/dev/null 2>&1 || docker network create web
|
|
docker compose build
|
|
docker compose up -d
|
|
docker compose ps
|
|
|
|
- name: Clean up old images
|
|
run: |
|
|
docker image prune -f
|
|
|
|
- name: Verify deployment
|
|
run: |
|
|
for i in $(seq 1 24); do
|
|
if curl -sf http://localhost:8080/health >/dev/null; then
|
|
echo "Healthy after $((i*5))s"
|
|
exit 0
|
|
fi
|
|
sleep 5
|
|
done
|
|
echo "Health check failed after 120s"
|
|
exit 1
|