Skip to content

Public-repo hosted Hub Pages CD (free Actions minutes) ​

CD — Hub Pages can run on GitHub-hosted runners in the public orchestrator repo (marklovely/lovely-hub-provision) so build + wrangler deploys do not queue serially on the VPS. The private repo runs a dispatch-and-wait job on ubuntu-latest: it triggers the public workflow, polls until that run finishes, and fails the private job if the public run fails (with the public run URL in the logs). Default wait timeout is 90 minutes (PUBLIC_CD_WAIT_TIMEOUT_MINUTES / PUBLIC_CD_WAIT_TIMEOUT_MS; the workflow sets 110 minutes to stay under the job’s 120-minute limit).

Billing: workflow files live in the public repo → no private-repo Actions minutes for resolve, build, and deploy jobs. The private dispatch job uses a few hosted seconds on the private repo when you trigger CD manually (acceptable volume).

Which token is which? ​

Same PAT pairing as public-ci-dispatch.md. GitHub shows PAT names under Developer settings; Actions uses repository secret names.

Your fine-grained PAT (settings label)Stored as secret onRepoPAT permissions (resource)
PUBLIC_CI_DISPATCH_TOKENPUBLIC_CI_DISPATCH_TOKENhome-dashboard (private)lovely-hub-provision: Actions Read and write
HOME_DASHBOARD_DISPATCH_TOKENHOME_DASHBOARD_DISPATCH_TOKENlovely-hub-provision (public)home-dashboard: Contents Read (Commit statuses not required for CD)

If your existing HOME_DASHBOARD_DISPATCH_TOKEN already has Contents read for PR CI statuses, reuse it for CD checkout — no second checkout PAT is required unless you split tokens for policy reasons.

Cloudflare credentials live only on the public repo (used during deploy matrix jobs):

SecretRepo
CLOUDFLARE_API_TOKENlovely-hub-provision
CLOUDFLARE_ACCOUNT_IDlovely-hub-provision

Copy values from the private repo (or your password manager); never commit them. Workflow logs on the public repo are world-readable like any public Actions run — same consideration as hub provision on the public orchestrator. So each hub's deploy runs through scripts/run-quiet-deploy.mjs (#1227): wrangler's output goes to a file, the log gets one line per hub, and a failed deploy's full log goes to private R2. See public-deploy-dispatch.md.

mermaid
flowchart LR
  subgraph private["home-dashboard"]
    DISPATCH[cd-hub-pages dispatch job]
    S1[PUBLIC_CI_DISPATCH_TOKEN]
  end
  subgraph public["lovely-hub-provision"]
    WH[hub-cd-dispatch.yml]
    S2[HOME_DASHBOARD_DISPATCH_TOKEN]
    CF[CLOUDFLARE_* secrets]
  end
  DISPATCH -->|workflow_dispatch| WH
  S1 -.-> DISPATCH
  S2 -.-> WH
  CF -.-> WH
  WH -->|checkout @ SHA| HD[(home-dashboard)]
  WH -->|wrangler| Pages[Cloudflare Pages hubs]

Architecture ​

mermaid
sequenceDiagram
  participant Op as Operator
  participant Priv as home-dashboard
  participant Pub as lovely-hub-provision
  participant GH as ubuntu-latest

  Op->>Priv: workflow_dispatch CD — Hub Pages
  Priv->>Pub: workflow_dispatch hub-cd-dispatch.yml
  Pub->>GH: resolve + build (once)
  par Parallel deploy matrix
    GH->>GH: deploy site 1
    GH->>GH: deploy site 2
    GH->>GH: deploy site N
  end

The build job uploads only dist/ (the front end every hub serves, kept one day, #1169). With a single upload path the artifact holds dist/'s contents at its root, so each deploy job downloads it with path: dist; without that the files land in the workspace root and the deploy stops with "Missing dist/" (#1194). Each deploy job stages its own Pages Functions.

Deploy jobs use strategy.max-parallel: 6 (template default) with fail-fast: false. GitHub-hosted org concurrency is typically 20 simultaneous jobs on free/team plans; raise max-parallel toward 10 if the terraform-managed fleet grows beyond six hubs.

One-time setup ​

1. Public repo workflow ​

In marklovely/lovely-hub-provision, .github/workflows/hub-cd-dispatch.yml on main.

bash
node scripts/sync-public-cd-workflow.mjs --repo marklovely/lovely-hub-provision

Or copy public-repo-workflow-template-cd-dispatch.yml manually.

2. Secrets on the public repo (lovely-hub-provision) ​

SecretValue
HOME_DASHBOARD_REPOmarklovely/home-dashboard
HOME_DASHBOARD_DISPATCH_TOKENPAT with Contents read on private repo
CLOUDFLARE_API_TOKENSame capability as private CD (Pages deploy)
CLOUDFLARE_ACCOUNT_IDCloudflare account id
bash
gh secret set HOME_DASHBOARD_DISPATCH_TOKEN --repo marklovely/lovely-hub-provision
gh secret set HOME_DASHBOARD_REPO --body 'marklovely/home-dashboard' --repo marklovely/lovely-hub-provision
gh secret set CLOUDFLARE_API_TOKEN --repo marklovely/lovely-hub-provision
gh secret set CLOUDFLARE_ACCOUNT_ID --repo marklovely/lovely-hub-provision

(HOME_DASHBOARD_REPO / checkout PAT may already exist from public CI setup.)

3. Secret on the private repo (home-dashboard) ​

SecretValue
PUBLIC_CI_DISPATCH_TOKENPAT with Actions write on public repo (same as PR CI)

Optional repo variable PUBLIC_CI_REPO (default marklovely/lovely-hub-provision).

4. Merge private-repo changes ​

Ensure main includes thin .github/workflows/cd-hub-pages.yml and scripts/dispatch-public-hub-cd.mjs, scripts/sync-public-cd-workflow.mjs.

Run CD after merge ​

  1. Merge app changes to main (or note the commit SHA you want live).
  2. GitHub → home-dashboard → Actions → CD — Hub Pages → Run workflow.
  3. Optional ref: branch/tag/SHA to deploy (default: repo default branch tip when you run from UI).
  4. sites: all or comma-separated hub ids.
  5. The private job stays in progress until the public run finishes; the log prints the public run URL and ends red if any deploy failed.

Local dispatch (requires env vars; waits by default):

bash
export CHECKOUT_SHA="$(git rev-parse main)"
export SITES=all
export PUBLIC_CI_DISPATCH_TOKEN=...
node scripts/dispatch-public-hub-cd.mjs

Skip waiting (fire-and-forget): PUBLIC_CD_WAIT=false node scripts/dispatch-public-hub-cd.mjs

Rollback (VPS-only CD) ​

Restore the previous .github/workflows/cd-hub-pages.yml from git history (self-hosted resolve / build / deploy jobs with CLOUDFLARE_* on the private repo). Remove or ignore hub-cd-dispatch.yml on the public repo if desired. Unset PUBLIC_CI_DISPATCH_TOKEN only if you also revert public CI dispatch.