Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
ci: refuse a preview build carrying Pages Functions
Elian Doran50eee50915c5
diff --git a/.github/workflows/cloudflare-preview.yml b/.github/workflows/cloudflare-preview.ymlindex 87c65e4a7a..d24426f709 100644--- a/.github/workflows/cloudflare-preview.yml+++ b/.github/workflows/cloudflare-preview.yml@@ -95,6 +95,22 @@ jobs:core.setOutput('number', String(claimed));+ # download-artifact confines the artifact to preview/, and nothing here runs+ # what it holds. Cloudflare Pages does run functions/ and _worker.js though,+ # server-side, where the project's bindings are reachable. None of the three+ # sites uses them, so a build that carries them is not a build to publish.+ # _headers and _redirects stay: apps/standalone/public/_headers sets the+ # cross-origin isolation the app needs.+ - name: Reject server-side entry points+ shell: bash+ run: |+ found=$(find preview -maxdepth 1 \( -name functions -o -name '_worker.js' -o -name '_routes.json' \) -print)+ if [ -n "$found" ]; then+ echo "::error::The build carries Cloudflare Pages Functions entry points, which this preview does not publish:"+ echo "$found"+ exit 1+ fi+# Install wrangler globally to avoid workspace issues- name: Install Wranglershell: bashdiff --git a/docs/Developer Guide/Developer Guide/Concepts/CI/Main.md b/docs/Developer Guide/Developer Guide/Concepts/CI/Main.mdindex 65af84c2ac..285edaac92 100644--- a/docs/Developer Guide/Developer Guide/Concepts/CI/Main.md+++ b/docs/Developer Guide/Developer Guide/Concepts/CI/Main.md@@ -33,5 +33,6 @@ Two consequences are worth knowing:* `cloudflare-preview.yml` must never check out the pull request's head or install its dependencies. It holds the Cloudflare credentials, and running fork-authored code beside them would hand those credentials away. Its only fork-controlled input is a directory of static files passed to `wrangler`.* A pull request can edit the workflow that writes the artifacts, so the pull request number it claims is checked against `workflow_run.head_sha` before it is used.+* The build is served as static files, but Cloudflare Pages runs a `functions/` directory and `_worker.js` server-side, where the project's bindings are reachable. None of the three sites uses them, so a build carrying one fails the deploy rather than publishing it. `_headers` and `_redirects` are published as usual; `apps/standalone/public/_headers` sets the cross-origin isolation the app needs.Because GitHub only triggers `workflow_run` from workflow files on the default branch, changes to `deploy-previews.yml` and `cloudflare-preview.yml` take effect once they are merged into `main` and cannot be exercised from a branch.