Files
zpan/.github/workflows/deploy.yml
T
saltbo 07973b6520 ci(deploy): fan-out dispatcher — one push, only configured platforms run
Previously, push to master triggered 6 separate deploy workflows (CF +
5 new v2.5.0 targets). If the fork hadn't configured, say, AWS or Azure
secrets, those workflows would run just to fail on "Check required
secrets" — producing 5 red X's in Actions tab per push, 5 failure
notifications, 5 wasted runner allocations.

Collapse to one top-level `deploy.yml` dispatcher that:

1. Runs a lightweight `detect` job (~5s) probing which platform secret
   bundles are fully present — without invoking secrets.* in job-level
   `if:` (which GH disallows).
2. Invokes the corresponding reusable child workflow via `uses:` +
   `secrets: inherit` only when that platform's flag is true.

Each child workflow (`deploy-<target>.yml`) is now a reusable workflow:
- `push: [master]` trigger → removed (dispatcher owns push)
- `workflow_call:` trigger → added (invoked by dispatcher)
- `workflow_dispatch:` trigger → kept (manual runs via Actions UI)
- `if: github.repository != 'saltbo/zpan'` job guard → removed
  (dispatcher enforces this once)

The old `deploy.yml` (CF Workers flow) is renamed to
`deploy-cloudflare.yml` for consistency with the other 5. Content of
the CF flow is unchanged.

For a fork with only CF configured: 1 dispatcher run + 1 cloudflare run.
For a fork with nothing configured: 1 dispatcher run with all 6 child
jobs shown as "Skipped" (not failed), and a ::notice:: pointing at the
README secrets table.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:22:44 -04:00

96 lines
3.6 KiB
YAML

name: Deploy
# Fan-out dispatcher for ZPan's 6 deployment targets.
#
# On push to master (or manual trigger), a quick `detect` job probes which
# platform secrets are configured and sets one output per platform. Each
# platform's reusable child workflow (deploy-<target>.yml) is invoked only
# when its flag is `true` — platforms you haven't configured are shown as
# "Skipped", not failed.
#
# The upstream saltbo/zpan repo uses Cloudflare Workers Builds (the CF-side
# git integration) for its own deploys — this dispatcher is a no-op there.
# Forks get the full fan-out.
on:
push:
branches: [master]
workflow_dispatch:
concurrency:
group: deploy-dispatch
cancel-in-progress: false
jobs:
detect:
name: Detect configured platforms
runs-on: ubuntu-latest
if: github.repository != 'saltbo/zpan'
outputs:
cf: ${{ steps.probe.outputs.cf }}
lambda: ${{ steps.probe.outputs.lambda }}
vercel: ${{ steps.probe.outputs.vercel }}
netlify: ${{ steps.probe.outputs.netlify }}
azure: ${{ steps.probe.outputs.azure }}
cloud_run: ${{ steps.probe.outputs.cloud_run }}
steps:
- id: probe
# secrets are smuggled into env as booleans so the following shell
# can evaluate them; secrets.* is not allowed in job-level `if:`.
env:
CF: ${{ secrets.CLOUDFLARE_API_TOKEN != '' && secrets.CLOUDFLARE_ACCOUNT_ID != '' }}
LAMBDA: ${{ secrets.AWS_ACCESS_KEY_ID != '' && secrets.AWS_SECRET_ACCESS_KEY != '' && secrets.AWS_REGION != '' && secrets.TURSO_DATABASE_URL != '' }}
VERCEL: ${{ secrets.VERCEL_TOKEN != '' && secrets.VERCEL_ORG_ID != '' && secrets.VERCEL_PROJECT_ID != '' && secrets.TURSO_DATABASE_URL != '' }}
NETLIFY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' && secrets.TURSO_DATABASE_URL != '' }}
AZURE: ${{ secrets.AZURE_CREDENTIALS != '' && secrets.TURSO_DATABASE_URL != '' }}
CLOUD_RUN: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY != '' && secrets.GCP_PROJECT_ID != '' && secrets.TURSO_DATABASE_URL != '' }}
run: |
configured=""
for p in CF LAMBDA VERCEL NETLIFY AZURE CLOUD_RUN; do
v=$(eval echo \$$p)
key=$(echo "$p" | tr '[:upper:]' '[:lower:]')
echo "${key}=${v}" >> "$GITHUB_OUTPUT"
[ "$v" = "true" ] && configured="$configured $p"
done
if [ -z "$configured" ]; then
echo "::notice::No deploy targets configured. Add secrets under Settings → Secrets and variables → Actions. See README for per-platform requirements."
else
echo "### 🚀 Dispatching to:$configured" >> "$GITHUB_STEP_SUMMARY"
fi
cloudflare:
needs: detect
if: needs.detect.outputs.cf == 'true'
uses: ./.github/workflows/deploy-cloudflare.yml
secrets: inherit
aws-lambda:
needs: detect
if: needs.detect.outputs.lambda == 'true'
uses: ./.github/workflows/deploy-aws-lambda.yml
secrets: inherit
vercel:
needs: detect
if: needs.detect.outputs.vercel == 'true'
uses: ./.github/workflows/deploy-vercel.yml
secrets: inherit
netlify:
needs: detect
if: needs.detect.outputs.netlify == 'true'
uses: ./.github/workflows/deploy-netlify.yml
secrets: inherit
azure:
needs: detect
if: needs.detect.outputs.azure == 'true'
uses: ./.github/workflows/deploy-azure.yml
secrets: inherit
cloud-run:
needs: detect
if: needs.detect.outputs.cloud_run == 'true'
uses: ./.github/workflows/deploy-cloud-run.yml
secrets: inherit