Files
golfgame/.gitea/workflows/deploy-staging.yml
adlee-was-taken d7631ec671
All checks were successful
Build & Deploy Staging / build-and-deploy (release) Successful in 1m27s
Fix CI: remove checkout step, runner can't resolve gitea hostname
The build happens on the staging server via SSH, not in the runner
container, so checkout is unnecessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 19:51:54 -04:00

51 lines
1.6 KiB
YAML

name: Build & Deploy Staging
on:
release:
types: [published]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Build, push, and deploy to staging
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.STAGING_HOST }}
username: root
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
set -e
TAG="${{ github.ref_name }}"
IMAGE="git.adlee.work/alee/golfgame"
cd /opt/golfgame
# Pull latest code and checkout the release tag
git fetch origin
git checkout "$TAG"
# Build the image
docker build -t "$IMAGE:$TAG" -t "$IMAGE:latest" -t golfgame-app:latest .
# Push to Gitea container registry
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.adlee.work -u "${{ secrets.REGISTRY_USER }}" --password-stdin
docker push "$IMAGE:$TAG"
docker push "$IMAGE:latest"
# Restart app (no --build, image already tagged)
docker compose -f docker-compose.staging.yml up -d app
# Wait for healthy
echo "Waiting for health check..."
for i in $(seq 1 30); do
if docker compose -f docker-compose.staging.yml ps app | grep -q "healthy"; then
echo "Staging deploy successful — $TAG"
exit 0
fi
sleep 2
done
echo "WARNING: app not healthy after 60s"
docker compose -f docker-compose.staging.yml logs --tail=20 app
exit 1