name: Deploy on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest container: volumes: - /opt:/opt steps: - name: Deploy run: | cd /opt/xbid git pull # Build both images up front. `migrate` targets the Dockerfile's # builder stage, which `app` also builds through, so the layers are # shared and this costs no extra build time. The profile is named # explicitly rather than relying on a service name activating it. docker compose --profile tools build app migrate # Apply pending migrations before the new app serves traffic. This # exits non-zero if a migration fails, failing the deploy rather than # starting an app whose schema is behind its code. docker compose --profile tools run --rm migrate docker compose up -d docker image prune -f