RYP-E3 in Wave P. ADR RY-0004 records the evidence that path A exists (Cloudflare self-managed OAuth clients, changelog 2026-06-03, authorization code flow only) and builds it; path B stays the written fallback; path C stays rejected. - railyard link: one URL; at most two consents in the browser (install the Railyard GitHub App on the repo, then Cloudflare's own consent screen with PKCE), each skipped when done before; then one pull request from the App on railyard/ship-on-push adding .github/workflows/railyard.yml. Nothing is pushed to a default branch. The installation id GitHub sends back is not trusted; the App's view of the repo decides. - The workflow holds no key: it asks GitHub for an OIDC token (audience = the console) and runs `railyard ci`. The console checks issuer, audience, expiry and signature, the stable repository_id, the Railyard workflow ref only, push/workflow_dispatch on branches only, and a paused org; it answers with a short-lived Cloudflare access token (sealed refresh token rotated and resealed; a cached access token reused while 10 min are left). - railyard ci masks the token first, deploys exactly like railyard deploy, never opens a login, and reports with a fresh OIDC token. The console records the deploy (branch and commit from the token) and writes one preview comment on the branch's pull request, edited on later pushes. - Signed App webhooks drop links on uninstall or repo removal. - GET /api/v1/github/manifest creates the App (owner item Y4); the done page shows one command that pipes the App key into wrangler secrets. - Migration 0007_ship.sql (idempotent; scratch Postgres only): installations, links (one per repo), sealed Cloudflare grants, link sessions; RLS on, no anon/authenticated grants. - Off until RAILYARD_SHIP_ON_PUSH_LIVE=1 and every name is set (routes 503; copy stays "arriving" under denylist rule railyard-slot-ship-on-push). Env: RAILYARD_SHIP_ON_PUSH_LIVE, GITHUB_APP_ID, GITHUB_APP_SLUG, GITHUB_APP_PRIVATE_KEY, GITHUB_APP_WEBHOOK_SECRET, CLOUDFLARE_OAUTH_CLIENT_ID, CLOUDFLARE_OAUTH_CLIENT_SECRET, CLOUDFLARE_OAUTH_SCOPES (optional); reuses RAILYARD_CREDENTIALS_KEY. Tests: console 122/122 (ship 12, migration 0007 on a scratch cluster), tsc clean; CLI 18/18 (link and ci 5, copy lint). The 5-minute push-to-live run on a real repo and Cloudflare account is owner-run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
// The one workflow file ship on push adds to a repository (PY3.1). It holds no
|
|
// key and no secret reference: the job asks GitHub for an OIDC token (audience
|
|
// = the console) and `railyard ci` exchanges it for a short-lived Cloudflare
|
|
// token. Builds run on the customer's own GitHub Actions minutes.
|
|
|
|
export const WORKFLOW_PATH = ".github/workflows/railyard.yml";
|
|
export const CLI_VERSION = "0.1.0";
|
|
|
|
export function workflowYaml(opts: { consoleUrl: string; productionBranch: string; cliVersion?: string }): string {
|
|
const console = opts.consoleUrl.replace(/\/$/, "");
|
|
if (!/^https:\/\/[a-z0-9.-]+(:\d+)?$/i.test(console)) throw new Error("console URL must be https");
|
|
const version = opts.cliVersion ?? CLI_VERSION;
|
|
return `# Railyard: deploy to your own Cloudflare account on push.
|
|
# A push to ${opts.productionBranch} goes live; a push to any other branch deploys a preview
|
|
# and Railyard posts its URL on that branch's pull request.
|
|
# No key is stored in this repository. The job proves which repository it runs for
|
|
# with GitHub's OIDC token; Railyard answers with a short-lived Cloudflare token.
|
|
name: Railyard
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
workflow_dispatch: {}
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: railyard-\${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
- name: Install dependencies
|
|
run: |
|
|
if [ -f package-lock.json ]; then npm ci
|
|
elif [ -f pnpm-lock.yaml ]; then corepack enable && pnpm install --frozen-lockfile
|
|
elif [ -f yarn.lock ]; then corepack enable && yarn install --frozen-lockfile
|
|
elif [ -f package.json ]; then npm install
|
|
fi
|
|
- name: Deploy
|
|
run: npx --yes railyard@${version} ci
|
|
env:
|
|
RAILYARD_CONSOLE_URL: ${console}
|
|
`;
|
|
}
|