name: Consumer Deploy # Reusable production deploy for generated child repos — never runs in this # repo. The caller owns triggers, permissions policy, and secrets (pass # `secrets: inherit` or map them explicitly). Runs the child's deploy command # (`pnpm run bos deploy`) from `working_directory`. Legs are tier-aware: a # child runtime (no Dockerfile) inherits the root's universal image — its # image ref derives from the platform release manifest (`platform` pin, # ADR 0034), the Railway leg repoints the service source to that pin and # redeploys, and the smoke gate boots the pinned digest when `smoke: true`. # A root runtime (Dockerfile or BOS_IMAGE) builds/pushes and pins the digest. # The deploy exits 0 whenever the config publishes and no leg failed — # `RAILWAY_TOKEN` is optional. on: workflow_call: inputs: working_directory: description: 'Directory exposing the repo''s standard scripts (default: repo root)' required: false type: string default: . verbose: description: Show full build output instead of clean summary required: false type: boolean default: false smoke: description: Boot-gate the pinned image against the published config before Railway required: false type: boolean default: false storage_origin: description: 'Upload service origin (self-hosted apps/upload deployments override the default)' required: false type: string default: https://upload.everything.dev permissions: contents: read packages: write jobs: deploy: name: Deploy runs-on: ubuntu-24.04 timeout-minutes: 45 defaults: run: working-directory: ${{ inputs.working_directory }} shell: bash # Secrets and deployment inputs live on the step that consumes them — # not at job level, where every step (including third-party actions') # would see them. steps: - name: Checkout code uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 (Node 24) with: ref: ${{ github.event.workflow_run.head_sha || github.sha }} - name: Guard — no stray bun artifacts run: | if [ -f bun.lock ]; then echo "::error::bun.lock present — bun re-migrated the workspace (ADR 0026). Delete bun.lock and re-run pnpm install." exit 1 fi - name: Setup pnpm uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - name: Setup Node uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: "24" - name: Get pnpm store dir id: pnpm-cache run: echo "STORE_PATH=$(pnpm store path)" >> "$GITHUB_OUTPUT" - name: Cache pnpm store uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 (Node 24) with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm- - name: Install dependencies run: pnpm install --frozen-lockfile --ignore-scripts # The Railway deploy leg shells out to the `railway` CLI — runners don't # ship it, and a missing binary surfaces as a failed leg after the config # has already published ("Config published but Railway CLI not found"). # Pinned to the current major; bump deliberately. - name: Install Railway CLI run: npm i -g @railway/cli@^5 - name: Deploy (preflight → build → upload → publish → image → smoke → Railway) timeout-minutes: 35 env: NEAR_PRIVATE_KEY: ${{ secrets.NEAR_PRIVATE_KEY }} BOS_STORAGE_ORIGIN: ${{ inputs.storage_origin }} BOS_STORAGE_API_KEY: ${{ secrets.BOS_STORAGE_API_KEY }} RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} # Railway token scopes differ by verb: a project-scoped RAILWAY_TOKEN # authorizes redeploy commands only; the child repoint (`railway service # source connect`, the serviceConnect mutation) needs workspace scope — # set RAILWAY_API_TOKEN (workspace token from railway.com/account/tokens) # plus the project/environment targeting vars and it owns the whole leg. RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }} RAILWAY_PROJECT_ID: ${{ vars.RAILWAY_PROJECT_ID }} RAILWAY_ENVIRONMENT_ID: ${{ vars.RAILWAY_ENVIRONMENT_ID }} run: pnpm run bos deploy${{ inputs.verbose == true && ' --verbose' || '' }}${{ inputs.smoke == true && ' --smoke' || '' }} # Drift alarm (#826): the pin→bytes proof — SRI every pinned version # manifest and hash every file it names against the served bytes; # compare the authored release against the parent's live release. # NON-BLOCKING by policy: rot names the files and the runbook, drift is # advisory. A child CLI predating the `verify` command fails here too — # still non-blocking (upgrade the framework to get the command). - name: Verify published pins (drift alarm, non-blocking) continue-on-error: true timeout-minutes: 10 run: | set -o pipefail if pnpm run bos verify --json 2>&1 | tee verify-report.txt; then { echo "### Pin verification — every published pin resolves byte-for-byte" echo '```' cat verify-report.txt echo '```' } >> "$GITHUB_STEP_SUMMARY" else echo "::warning::Pin verification FAILED — a published pin no longer resolves byte-for-byte (rot, #826). Run \`bos upgrade && bos deploy\` to re-pin." { echo "### Pin verification FAILED (rot, #826)" echo '```' cat verify-report.txt echo '```' echo "Run \`bos upgrade && bos deploy\` to re-pin." } >> "$GITHUB_STEP_SUMMARY" fi