Files
linearvoid/.gitea/workflows/cd.yml
T
zwitschi 43c1a31660
CI / test (push) Successful in 1m39s
CI / docker (push) Successful in 3m4s
CI / release (push) Skipped
CD / deploy (push) Failing after 1m17s
fix: nginx build context, playout health check retry loop
2026-08-04 10:21:18 +02:00

95 lines
2.9 KiB
YAML

name: CD
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: [ubuntu-latest]
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: git.allucanget.biz
username: ${{ secrets.CI_REGISTRY_USER }}
password: ${{ secrets.CI_REGISTRY_TOKEN }}
- name: Prepare environment
run: |
cat > .env << 'EOF'
DATABASE_URL="${{ secrets.DATABASE_URL }}"
REDIS_URL=redis://redis:6379/0
PLAYLIST_PATH=/app/playlist/playlist.txt
HLS_SEGMENT_DURATION=6
HLS_WINDOW_SIZE=24
LOG_LEVEL=info
ADMIN_USERNAME="${{ secrets.ADMIN_USERNAME }}"
ADMIN_PASSWORD="${{ secrets.ADMIN_PASSWORD }}"
ADMIN_SESSION_TTL_HOURS=12
NGINX_PORT=80
EOF
- name: Seed Prometheus config
run: |
mkdir -p monitoring/prometheus
cat > monitoring/prometheus/prometheus.yml << 'EOF'
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'linearvoid'
static_configs:
- targets: ['playout:8081', 'chat:3000', 'nginx:80']
EOF
- name: Deploy with docker-compose
env:
DOCKER_HOST: tcp://192.168.88.40:2375
run: |
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d --remove-orphans
- name: Health check
env:
DOCKER_HOST: tcp://192.168.88.40:2375
run: |
# Wait for playout to stabilize (it may restart during init)
sleep 20
curl -f http://192.168.88.40:3000/health || exit 1
# Retry playout health check since it may still be initializing
for i in $(seq 1 6); do
if docker exec linearvoid-playout curl -sf http://localhost:8081/health; then
echo "Playout is healthy"
exit 0
fi
echo "Playout not ready yet (attempt $i/6), waiting 5s..."
sleep 5
done
echo "Playout failed to become healthy after 6 attempts"
docker logs linearvoid-playout --tail 50
exit 1
curl -f http://192.168.88.40:3000/health || exit 1
docker exec linearvoid-playout curl -sf http://localhost:8081/health || exit 1
- name: Cleanup old images
env:
DOCKER_HOST: tcp://192.168.88.40:2375
run: |
docker image prune -f --filter "until=24h"