Skip to content

Commit 355f798

Browse files
committed
ci: induce the standalone Next output so the tested bundle can be packaged
`opennextjs-cloudflare build --skipNextBuild` reads `.next/standalone/apps/docs/.next/server/pages-manifest.json`, and a plain `next build` writes no `.next/standalone/` at all — so the packaging step added in the previous commit failed with ENOENT on that path. Measured, not guessed: CI run 33879772449 on this branch. The reason is that `output: 'standalone'` is not in `next.config.mjs`; `@opennextjs/aws` sets `NEXT_PRIVATE_STANDALONE=true` before it runs the Next build itself, with the comment "Equivalent to setting `output: \"standalone\"` in next.config.js". Skipping its build skipped that too. So the env var is set on the `build` job instead of editing `apps/docs/next.config.mjs`, which is outside this card's file surface and would change how the app builds for every consumer rather than only in CI. It must also be declared in `turbo.json`: turbo 2 runs tasks in strict env mode, so an undeclared variable never reaches `next build` — and declaring it is what puts it in the cache key, so a `.next` cached from before this change cannot be replayed without the standalone tree the packaging step needs. Also adds a TEMPORARY `verify-plumbing` job, removed before merge, that runs the rollback job's own `gh workflow run` command with the same GITHUB_TOKEN and `actions: write` and confirms from the API that a run was really created. That path only ever executes during an outage, and if GITHUB_TOKEN cannot dispatch a workflow here the automatic rollback would silently never fire. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GkauAsZBEemRbco2rEX9Lx
1 parent e7e7258 commit 355f798

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ jobs:
4545

4646
build:
4747
runs-on: ubuntu-latest
48+
# `NEXT_PRIVATE_STANDALONE` is what `@opennextjs/aws` sets before it runs
49+
# `next build` — its own comment reads "Equivalent to setting `output:
50+
# "standalone"` in next.config.js". Without it a plain `next build`
51+
# produces no `.next/standalone/`, and the packaging step below fails on a
52+
# missing `pages-manifest.json` three directories inside it. Measured on
53+
# this branch before it was set: `ENOENT ... .next/standalone/apps/docs/
54+
# .next/server/pages-manifest.json`.
55+
#
56+
# Set for the whole job rather than for the deploy path only, so that what
57+
# a pull request builds is the same shape as what gets published. A build
58+
# that differs from the deploy build is a small instance of the defect this
59+
# card is about.
60+
#
61+
# It has to be declared in `turbo.json` as well: turbo 2 runs tasks in
62+
# strict env mode, so an undeclared variable never reaches `next build` —
63+
# and declaring it is also what puts it in the cache key, so a `.next`
64+
# cached from before this line cannot be replayed without the standalone
65+
# tree the packaging step needs.
66+
env:
67+
NEXT_PRIVATE_STANDALONE: 'true'
4868
steps:
4969
- uses: actions/checkout@v7
5070
- uses: pnpm/action-setup@v6

‎.github/workflows/deploy-docs.yml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ on:
8181
required: false
8282
type: boolean
8383
default: false
84+
verify_plumbing:
85+
description: 'TEMPORARY (removed before merge). Prove GITHUB_TOKEN can dispatch rollback-docs.yml at all.'
86+
required: false
87+
type: boolean
88+
default: false
8489

8590
jobs:
8691
deploy:
@@ -331,3 +336,54 @@ jobs:
331336
URL="$(gh issue create --title "$TITLE" --label "$LABEL" --body "$BODY")"
332337
echo "::notice::filed $URL"
333338
fi
339+
340+
# TEMPORARY — removed before this PR merges.
341+
#
342+
# The `rollback` job above is the one part of this pipeline that only ever
343+
# runs during an outage, and it depends on something not obvious: whether
344+
# GITHUB_TOKEN is allowed to dispatch a workflow at all. GitHub suppresses
345+
# workflow triggering from token-driven events in several cases; if that
346+
# applied here the automatic rollback would silently never happen, which is
347+
# the exact failure class this card exists to eliminate.
348+
#
349+
# So: run the same command, with the same token and the same permission, and
350+
# confirm from the API that a run was really created. `rollback-docs.yml`
351+
# with a blank `version_id` lists versions and changes nothing, so this is
352+
# safe to fire against production.
353+
verify-plumbing:
354+
name: TEMPORARY - prove the rollback dispatch fires
355+
if: inputs.verify_plumbing
356+
runs-on: ubuntu-latest
357+
permissions:
358+
contents: read
359+
actions: write
360+
steps:
361+
- uses: actions/checkout@v7
362+
- name: Dispatch rollback-docs.yml with a blank version_id
363+
env:
364+
GH_TOKEN: ${{ github.token }}
365+
GH_REPO: ${{ github.repository }}
366+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
367+
shell: bash
368+
run: |
369+
set -euo pipefail
370+
LATEST='repos/'"$GH_REPO"'/actions/workflows/rollback-docs.yml/runs?per_page=1'
371+
BEFORE="$(gh api "$LATEST" --jq '.workflow_runs[0].id // 0')"
372+
echo "latest rollback run before: $BEFORE"
373+
374+
gh workflow run rollback-docs.yml --ref "$DEFAULT_BRANCH" \
375+
-f version_id= \
376+
-f reason="plumbing check from the #269 branch: lists versions, changes nothing"
377+
378+
AFTER="$BEFORE"
379+
for _ in $(seq 1 24); do
380+
sleep 5
381+
AFTER="$(gh api "$LATEST" --jq '.workflow_runs[0].id // 0')"
382+
[ "$AFTER" != "$BEFORE" ] && break
383+
done
384+
385+
if [ "$AFTER" = "$BEFORE" ]; then
386+
echo "::error::GITHUB_TOKEN did NOT create a rollback-docs run — the automatic rollback would silently never fire"
387+
exit 1
388+
fi
389+
echo "::notice::rollback-docs.yml run $AFTER was created by GITHUB_TOKEN"

‎turbo.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"tasks": {
55
"build": {
66
"dependsOn": ["^build"],
7+
"env": ["NEXT_PRIVATE_STANDALONE"],
78
"inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/content/docs/**"],
89
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
910
},

0 commit comments

Comments
 (0)