diff --git a/.github/scripts/pages-static-assets.mjs b/.github/scripts/pages-static-assets.mjs index ca5ea6867..b5d1de4b4 100644 --- a/.github/scripts/pages-static-assets.mjs +++ b/.github/scripts/pages-static-assets.mjs @@ -42,7 +42,8 @@ export function prepareStaticAssets({ target, sourceRoot, destination, sourceSha } } check(output); - if (!existsSync(join(output, "index.html")) || !existsSync(join(output, "_headers"))) throw new Error("Frontend index and response headers required"); + const isRegularFile = (name) => existsSync(join(output, name)) && lstatSync(join(output, name)).isFile(); + if (!isRegularFile("index.html") || !isRegularFile("_headers")) throw new Error("Frontend index and response headers required"); if (existsSync(join(output, "_worker.js")) || existsSync(join(output, "_routes.json"))) throw new Error("Only static artifacts are supported"); mkdirSync(dest, { recursive: true }); cpSync(output, join(dest, "assets"), { recursive: true }); diff --git a/.github/scripts/pages-static-assets.test.mjs b/.github/scripts/pages-static-assets.test.mjs index e96988949..1e10a23be 100644 --- a/.github/scripts/pages-static-assets.test.mjs +++ b/.github/scripts/pages-static-assets.test.mjs @@ -75,3 +75,12 @@ test("changed admin redirect behavior requires explicit review", () => { assert.throws(() => prepareStaticAssets({ target, sourceRoot: root, destination, sourceSha: sha, release: "v0.6.74" })); }); }); + +test("requires regular frontend entrypoint and response header files", () => { + for (const name of ["index.html", "_headers"]) fixture("web", ({ root, target, output, destination }) => { + rmSync(join(output, name)); + mkdirSync(join(output, name)); + assert.throws(() => prepareStaticAssets({ target, sourceRoot: root, destination, sourceSha: sha, release: "v0.6.74" }), /Frontend index and response headers required/); + assert.equal(existsSync(destination), false); + }); +}); diff --git a/.github/workflows/static-assets.yml b/.github/workflows/static-assets.yml index 616403559..37833c8b9 100644 --- a/.github/workflows/static-assets.yml +++ b/.github/workflows/static-assets.yml @@ -61,11 +61,19 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Pin the existing release source + env: + GH_TOKEN: ${{ github.token }} run: | [[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] [[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]] + gh release view "$RELEASE_TAG" --json isDraft,isPrerelease,publishedAt \ + | jq -e '.isDraft == false and .isPrerelease == false and .publishedAt != null' >/dev/null test "$(git rev-parse "refs/tags/$RELEASE_TAG^{commit}")" = "$SOURCE_SHA" git merge-base --is-ancestor "$SOURCE_SHA" origin/main + if ! git cat-file -e "$SOURCE_SHA:.github/scripts/pages-production-config.mjs"; then + echo '::error::Release does not support public Pages configuration import; select a supported release.' + exit 1 + fi git worktree add --detach "$RUNNER_TEMP/frontend-source" "$SOURCE_SHA" - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: diff --git a/docs/content/docs/development/configuration.mdx b/docs/content/docs/development/configuration.mdx index b1a0d7d19..abe9dc5a3 100644 --- a/docs/content/docs/development/configuration.mdx +++ b/docs/content/docs/development/configuration.mdx @@ -693,7 +693,9 @@ Self-hosted containers and their configuration are unchanged. For example, a staging entry is `[{"project":"dashboard-project","worker":"dashboard-assets-stage","domains":["assets-stage.example.com"]}]`. -No wildcard domain is accepted. Empty domains publish an unattached artifact; +No wildcard domain is accepted. Empty domains do not attach a new domain or +detach a custom domain attached by an earlier deployment. Remove an existing +binding in the Worker's **Settings > Domains & Routes** page when needed. `workers.dev` and preview URLs stay disabled. The publisher preserves `_headers` and the dashboard's `_redirects`. For admin it replaces the Pages catch-all rewrite with the platform's SPA fallback and keeps the other @@ -701,7 +703,9 @@ frontends' 404 behavior. It rejects symlinks, Pages Functions, files above 25 Mi and artifacts exceeding the Free plan's 20,000-file limit. The manual **Publish released static assets** workflow rebuilds an existing -stable release using its tag and exact commit SHA. It does not create a tag, +published stable release using its tag and exact commit SHA. It supports +v0.6.28 and later releases containing the public Pages configuration importer; +older tags fail the source check before publishing. It does not create a tag, release, application deployment or worker-fleet update. It uses current public Pages configuration, so a rebuilt artifact can differ from the earlier build if that configuration changed. The deployed artifact includes @@ -713,8 +717,10 @@ account's current limits and pricing before enabling any other Workers feature. Before moving a production hostname, verify the staging site's certificate, TLS policy, root and nested routes, assets, response headers and redirects. Archive its existing Pages association and DNS. If verification fails after a -cutover, restore that association and DNS, or deploy the saved asset artifact to -the same Worker name. Keep the Pages deployment and its configuration available +cutover, remove the Worker's custom-domain binding and restore that Pages +association and DNS. Redeploying the saved asset artifact to the same Worker +reapplies its custom-domain routes; it does not restore Pages or DNS. Keep the +Pages deployment and its configuration available through the rollback window. A source merge alone does not attach a domain. ### Whole-domain connects