Repository navigation
TS1: TanStack Start on Workers #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| # A MANUAL RUN. Orunbase's Run and Deploy buttons start this workflow on | |
| # main with component names, an environment and the deploy record's id | |
| # (the deploys contract: ci.yml on main; inputs component, environment, | |
| # deploy_id); "Run workflow" in the Actions tab does the same by hand. The | |
| # plan step plans those components in that environment under the | |
| # push-to-main trigger, so each one runs exactly as a merge runs it: stage | |
| # and prod apply and deploy, dev verifies. An empty `component` means | |
| # every component in the environment, a redeploy with nothing changed. | |
| workflow_dispatch: | |
| inputs: | |
| component: | |
| description: "Component names, comma-separated (component.yaml metadata.name); empty for every component" | |
| required: false | |
| type: string | |
| default: "" | |
| environment: | |
| description: "Target environment" | |
| required: true | |
| type: choice | |
| options: [dev, stage, prod] | |
| deploy_id: | |
| description: "Orunbase deploy record (dpl_…), set by Orunbase; appears in the run name" | |
| required: false | |
| type: string | |
| default: "" | |
| # A manual run names itself after what it runs: Orunbase finds a deploy's run | |
| # by the id in this name (GitHub's dispatch API returns no run id). Every | |
| # other event keeps GitHub's default name (an empty run-name falls back to it). | |
| run-name: ${{ github.event_name == 'workflow_dispatch' && format('Deploy {0} → {1} · {2}', inputs.component || 'every component', inputs.environment, inputs.deploy_id || 'by hand') || '' }} | |
| # PR runs share a group per ref and superseded runs are cancelled (each | |
| # push re-plans anyway), which stops stale fan-outs from starving the | |
| # runner pool. Main pushes get a unique group each: convergence runs plan | |
| # --changed per commit, and GitHub replaces *pending* runs in a shared | |
| # group even with cancel-in-progress false — a superseded main run's | |
| # components would silently never converge. | |
| concurrency: | |
| group: ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # A lane of several jobs posts one check run per job, named by the job's | |
| # check title, so branch protection sees the same names as before lanes. | |
| checks: write | |
| jobs: | |
| plan: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| lane-matrix: ${{ steps.matrix.outputs.lane-matrix }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| # A TREE THAT NAMES NO WORKSPACE PLANS NOTHING. `ws_CHANGE_ME` is the | |
| # placeholder this repository ships with until someone links it; every | |
| # remote op of a plan here would be refused, so the job says so and | |
| # stops green, and `run` below has no lanes to start. A site built from | |
| # this baseline never carries the placeholder — its bootstrap writes the | |
| # product's own workspace into intent.yaml — and a bootstrap that had no | |
| # workspace to write leaves `ws_SET_ME`, which is NOT skipped: it fails | |
| # here loudly rather than deploying nothing in silence. | |
| # | |
| # This replaced an `ORUN_CI` repository variable, which a bootstrap has | |
| # no way to set: every site it built would have converged on nothing. | |
| - id: linked | |
| run: | | |
| if grep -Eq '^[[:space:]]*workspace:[[:space:]]*ws_CHANGE_ME[[:space:]]*$' intent.yaml; then | |
| echo "::notice title=Orun CI::intent.yaml names no Orun workspace (ws_CHANGE_ME) — nothing to plan. Link this repository (orun cloud link) and set execution.state.workspace to turn the pipeline on." | |
| echo "linked=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "linked=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - if: steps.linked.outputs.linked == 'true' | |
| uses: sourceplane/orun-action@v1.2.0 | |
| with: | |
| version: v2.78.4 | |
| - if: steps.linked.outputs.linked == 'true' | |
| env: | |
| # Surface the best-effort catalog auto-sync (execution.state.autopushCatalog). | |
| # A successful push prints "✓ pushed catalog …"; ORUN_VERBOSE also makes | |
| # any skip/failure visible instead of silent. | |
| ORUN_VERBOSE: "1" | |
| # A manual run's selection, read from the environment, never | |
| # interpolated into the script. | |
| DISPATCH_COMPONENT: ${{ inputs.component }} | |
| DISPATCH_ENVIRONMENT: ${{ inputs.environment }} | |
| run: | | |
| set -euo pipefail | |
| if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then | |
| # A MANUAL RUN plans under the push-to-main trigger: the profiles | |
| # a merge runs, filtered to the environment and the components it | |
| # names. Not --changed: a redeploy is asked for when nothing has | |
| # changed. Main only, because that trigger deploys stage and prod. | |
| if [ "$GITHUB_REF" != "refs/heads/main" ]; then | |
| echo "::error title=Orun CI::A manual run deploys main only; this one was started on ${GITHUB_REF}." | |
| exit 1 | |
| fi | |
| plan_args=( | |
| --trigger github-push-main | |
| --env "$DISPATCH_ENVIRONMENT" | |
| --intent intent.yaml | |
| --output plan.json | |
| ) | |
| if [ -n "${DISPATCH_COMPONENT//[[:space:],]/}" ]; then | |
| # Keep the named components that have something to run in this | |
| # environment. orun refuses the others as unmatched (a test | |
| # suite has no job in prod), and a run of only those is nothing | |
| # selected, not a failure: it stays green with no lanes, which | |
| # Orunbase reads as nothing selected. | |
| orun plan --trigger github-push-main --env "$DISPATCH_ENVIRONMENT" \ | |
| --intent intent.yaml --output env-plan.json --no-catalog-refresh >/dev/null | |
| kept=0 | |
| IFS=',' read -ra picked <<< "$DISPATCH_COMPONENT" | |
| for c in "${picked[@]}"; do | |
| c="${c//[[:space:]]/}" | |
| [ -z "$c" ] && continue | |
| if ! [[ "$c" =~ ^[a-z0-9][a-z0-9._-]{0,99}$ ]]; then | |
| echo "::error title=Orun CI::'$c' is not a component name (component.yaml metadata.name)." | |
| exit 1 | |
| fi | |
| if jq -e --arg c "$c" 'any(.jobs[]; .component == $c)' env-plan.json >/dev/null; then | |
| plan_args+=(--component "$c") | |
| kept=$((kept + 1)) | |
| else | |
| echo "::notice title=Orun CI::$c has nothing to run in ${DISPATCH_ENVIRONMENT} (or is not a component); left out." | |
| fi | |
| done | |
| if [ "$kept" = 0 ]; then | |
| jq '.jobs = [] | .lanes = []' env-plan.json > plan.json | |
| plan_args=() | |
| fi | |
| fi | |
| else | |
| plan_args=( | |
| --from-ci github | |
| --event-file "$GITHUB_EVENT_PATH" | |
| --intent intent.yaml | |
| --output plan.json | |
| --changed | |
| ) | |
| fi | |
| if [ "${#plan_args[@]}" -gt 0 ]; then | |
| orun plan "${plan_args[@]}" | |
| fi | |
| # A manual run that selects nothing runs nothing, and says so. | |
| if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ] && [ "$(jq '.jobs | length' plan.json)" = 0 ]; then | |
| echo "::notice title=Orun CI::Nothing to run for ${DISPATCH_COMPONENT:-every component} in ${DISPATCH_ENVIRONMENT}." | |
| fi | |
| # One matrix entry per LANE (execution.lanes in intent.yaml). A plan | |
| # without lanes gets one per job, exactly the old matrix, and | |
| # `orun run --lane <job id>` on it is `--job <job id>`. | |
| - id: matrix | |
| if: steps.linked.outputs.linked == 'true' | |
| run: | | |
| echo "lane-matrix=$(jq -c 'if ((.lanes // []) | length) > 0 | |
| then [.lanes[] | {"lane": .id, "name": .name}] | |
| else [.jobs[] | {"lane": .id, "name": .checkName}] end' plan.json)" >> "$GITHUB_OUTPUT" | |
| - if: steps.linked.outputs.linked == 'true' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: orun-plan | |
| path: plan.json | |
| run: | |
| needs: plan | |
| runs-on: ubuntu-latest | |
| # A BOOTSTRAP LANDING IS CHECKED BY `plan` ALONE. Every phase of the | |
| # baseline bootstrap lands on a branch named for its task — the provenance | |
| # pen's `orun/<KEY>-<slug>`, and the bootstrap's tasks are all `BASE-n` — | |
| # and is merged by `orun.pr/land@v1` as soon as this workflow is green. | |
| # On those pull requests `plan` above is the check: the intent, every | |
| # component and every composition resolve, the changed set is computed, | |
| # and the plan is uploaded. The lanes are not run there, because the merge | |
| # runs every one of them again on main moments later, for real, and the | |
| # bootstrap watches that convergence to green before the next phase — the | |
| # PR pass was the same work twice, and a third of a bootstrap's wall-clock. | |
| # Every other pull request runs its lanes exactly as before. | |
| if: >- | |
| ${{ needs.plan.outputs.lane-matrix != '[]' && needs.plan.outputs.lane-matrix != '' | |
| && !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'orun/BASE-')) }} | |
| strategy: | |
| fail-fast: false | |
| # Stagger the fan-out: every lane hits the lease-bound resolve at job | |
| # start, and an unbounded herd (fifty lanes) saturated it twice. Sixteen | |
| # keeps the herd well under that and is above execution.lanes.maxLanes | |
| # (6), so a packed plan starts every lane at once; it only binds on a | |
| # small plan that runs one lane per job. Inside a lane a job that waits | |
| # on another lane holds no slot. | |
| max-parallel: 16 | |
| matrix: | |
| include: ${{ fromJson(needs.plan.outputs.lane-matrix) }} | |
| name: ${{ matrix.name }} | |
| env: | |
| # One pnpm store for every lane, restored below. Each lane installs the | |
| # whole workspace with --frozen-lockfile; without this every one of them | |
| # downloaded all ~500 packages from the registry again. | |
| npm_config_store_dir: /home/runner/.pnpm-store | |
| PNPM_STORE_DIR: /home/runner/.pnpm-store | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # Keyed by the lockfile alone, so every lane of every run shares one | |
| # entry until a dependency changes. The first lane to finish saves it; | |
| # the rest find the key taken and skip the save. | |
| - name: pnpm store cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: /home/runner/.pnpm-store | |
| key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| pnpm-store-${{ runner.os }}- | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: orun-plan | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: sourceplane/orun-action@v1.2.0 | |
| with: | |
| version: v2.78.4 | |
| # exec-id is the RUN id alone (no attempt suffix): a `gh run rerun | |
| # --failed` then RESUMES the same orun execution — jobs that succeeded in | |
| # a prior attempt stay completed, so re-run lanes' cross-job dependencies | |
| # are already satisfied instead of waiting forever on lanes that are not | |
| # re-running (the partial-rerun deadlock). --retry re-opens THIS | |
| # lane's failed jobs when they terminally failed in a prior attempt | |
| # (no-op on first attempts); its completed jobs stay completed — together | |
| # they make `gh run rerun --failed` a true resume. | |
| - run: | | |
| # --retry only on re-run attempts: on a fresh attempt a failed | |
| # upstream is a genuine failure and dependents must fail fast; on a | |
| # resume (gh run rerun --failed) the upstream's own retry lane will | |
| # re-open it, so lanes wait out the race instead. | |
| retry_flag="" | |
| if [ "${GITHUB_RUN_ATTEMPT:-1}" -gt 1 ]; then retry_flag="--retry"; fi | |
| # EVERY RUN REPORTS TO THE PLATFORM, a pull request's included. | |
| # | |
| # A PR lane resolves its secrets like any other (a verify lane still | |
| # reads the wiring its fixture stands in for, an infra lane plans | |
| # against the real account), and a job's secret refs are resolved | |
| # before its first step whatever its profile does — so a PR run | |
| # without remote state failed every lane that declares one: | |
| # | |
| # ✗ cloudflare-d1.stage.terraform: secret resolution failed: local | |
| # runs resolve secrets only from ORUN_SECRET_<KEY> overrides | |
| # | |
| # and a phase's PR could never be verified before it merged. This | |
| # used to drop the state flag on PRs, on the belief that the backend | |
| # refuses a pull_request OIDC token by design. It does not: the | |
| # exchange's only gate is the repo link's CI settings (oidcEnabled, | |
| # allowedRefPattern, allowedEnvironments — identity-worker | |
| # oidc-exchange.ts), and the resource-hidden `not_found` seen at the | |
| # time is exactly what an UNLINKED repository answers, push or PR. | |
| # Remote state on a PR also puts the PR's runs in front of the | |
| # platform, which renders runs on refs/pull/<n> as that PR's row. | |
| # Fork PRs get no OIDC token from GitHub at all and still fail | |
| # closed. Nothing mutating runs here: deploy/apply profiles are gated | |
| # on triggerRef github-push-main. | |
| state_flag="--remote-state" | |
| orun run \ | |
| --plan plan.json \ | |
| --runner github-actions \ | |
| $state_flag \ | |
| --lane "${{ matrix.lane }}" \ | |
| --exec-id "${{ github.run_id }}" \ | |
| $retry_flag | |
| env: | |
| # GITHUB_TOKEN is the only credential CI holds — GitHub-issued and | |
| # ephemeral. Every provider credential (the Cloudflare token and | |
| # account id — this baseline has no second provider) is an | |
| # orun-managed secret: | |
| # brokered fresh per run from the workspace's integrations, resolved | |
| # lease-bound by the jobs that declare it (profile secretBindings or | |
| # component secretEnv), and log-redacted. Nothing provider-shaped is | |
| # stored in GitHub. | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| DOCKER_CONFIG: /home/runner/.docker |