ci: unify deploy pipeline - sync to Gitea + self-hosted deploy
All checks were successful
Deploy API-Ubigeo / deploy (push) Successful in 13m52s
All checks were successful
Deploy API-Ubigeo / deploy (push) Successful in 13m52s
- GitHub: CI on ubuntu-latest (no more self-hosted) - GitHub: add sync-gitea.yml for auto-deploy trigger - Gitea: add deploy.yml with robust health check - Remove disabled deploy.yml.disabled
This commit is contained in:
48
.gitea/workflows/deploy.yml
Normal file
48
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Deploy API-Ubigeo
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Sync source
|
||||
run: |
|
||||
rsync -a --delete \
|
||||
--exclude='.git' \
|
||||
--exclude='node_modules' \
|
||||
--exclude='dist' \
|
||||
--exclude='.env' \
|
||||
./ /home/deployer/api-ubigeo/
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
cd /home/deployer/api-ubigeo
|
||||
docker build -t ubigeo-api:latest .
|
||||
|
||||
- name: Deploy containers
|
||||
run: |
|
||||
cd /home/deployer/api-ubigeo
|
||||
docker compose -f docker-compose.production.yml down --remove-orphans
|
||||
docker compose -f docker-compose.production.yml up -d
|
||||
|
||||
- name: Health check
|
||||
run: |
|
||||
echo "Waiting for API-Ubigeo to start..."
|
||||
for i in $(seq 1 15); do
|
||||
sleep 3
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:3200/api/v1/health 2>/dev/null || echo "000")
|
||||
if [ "$HTTP_CODE" != "000" ] && [ "$HTTP_CODE" != "502" ] && [ "$HTTP_CODE" != "503" ]; then
|
||||
echo "✅ Health check passed after $((i*3))s (HTTP $HTTP_CODE)"
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $i/15 - not ready yet (HTTP $HTTP_CODE)..."
|
||||
done
|
||||
echo "❌ Health check failed after 45s"
|
||||
docker logs ubigeo-api --tail 50
|
||||
exit 1
|
||||
Reference in New Issue
Block a user