Skip to content

Commit fd87584

Browse files
Add CI check for Cloudflare Worker build (nodejs#7743)
* chore: remove Cloudflare related pre-scripts in favour of turbo `dependsOn` configs * chore: add workflow to test Cloudflare Worker build on PRs and pushes * fixup! chore: add workflow to test Cloudflare Worker build on PRs and pushes remove windows since the OpenNext adapter is not compatible with it * fixup! chore: remove Cloudflare related pre-scripts in favour of turbo `dependsOn` configs add back `prebuild` script as that is needed for the vercel deployment * fixup! chore: add workflow to test Cloudflare Worker build on PRs and pushes Apply suggestions from code review Co-authored-by: Aviv Keller <me@aviv.sh> Signed-off-by: Dario Piotrowicz <dario.piotrowicz@gmail.com> * fixup! chore: add workflow to test Cloudflare Worker build on PRs and pushes remove unnecessary filter * fixup! chore: add workflow to test Cloudflare Worker build on PRs and pushes update incorrect `pull_request_target` to `pull_request` * Apply suggestions from code review Co-authored-by: Aviv Keller <me@aviv.sh> Signed-off-by: Dario Piotrowicz <dario.piotrowicz@gmail.com> --------- Signed-off-by: Dario Piotrowicz <dario.piotrowicz@gmail.com> Co-authored-by: Aviv Keller <me@aviv.sh>
1 parent 946448f commit fd87584

File tree

3 files changed

+79
-4
lines changed

3 files changed

+79
-4
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Security Notes
2+
# Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/nodejs.org/settings/actions)
3+
# for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions.
4+
# REVIEWERS, please always double-check security practices before merging a PR that contains Workflow changes!!
5+
# AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags.
6+
7+
name: Cloudflare OpenNext Build
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
pull_request:
14+
branches:
15+
- main
16+
17+
defaults:
18+
run:
19+
# This ensures that the working directory is the root of the repository
20+
working-directory: ./
21+
22+
permissions:
23+
contents: read
24+
actions: read
25+
26+
env:
27+
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--cache-dir
28+
TURBO_ARGS: --cache-dir=.turbo/cache
29+
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
30+
TURBO_FORCE: true
31+
32+
jobs:
33+
build-cloudflare-worker:
34+
name: Build Cloudflare Worker
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Harden Runner
39+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
40+
with:
41+
egress-policy: audit
42+
43+
- name: Git Checkout
44+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
46+
- name: Set up pnpm
47+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
48+
with:
49+
cache: true
50+
51+
- name: Set up Node.js
52+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
53+
with:
54+
# We want to ensure that the Node.js version running here respects our supported versions
55+
node-version-file: '.nvmrc'
56+
cache: 'pnpm'
57+
58+
- name: Install packages
59+
run: pnpm install --frozen-lockfile
60+
61+
- name: Build Cloudflare Worker
62+
run: pnpm exec turbo run cloudflare:build:worker ${{ env.TURBO_ARGS }}

apps/site/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"build": "cross-env NODE_NO_WARNINGS=1 next build",
77
"check-types": "tsc --noEmit",
88
"deploy": "cross-env NEXT_PUBLIC_STATIC_EXPORT=true NODE_NO_WARNINGS=1 next build",
9-
"predev": "pnpm build-blog-data",
109
"dev": "cross-env NODE_NO_WARNINGS=1 next dev",
1110
"lint": "turbo run lint:md lint:js lint:css",
1211
"lint:css": "stylelint \"**/*.css\" --allow-empty-input --cache --cache-strategy=content --cache-location=.stylelintcache",
@@ -23,8 +22,8 @@
2322
"build-blog-data": "node ./scripts/blog-data/generate.mjs",
2423
"build-blog-data:watch": "node --watch --watch-path=pages/en/blog ./scripts/blog-data/generate.mjs",
2524
"cloudflare:build:worker": "opennextjs-cloudflare build",
26-
"cloudflare:preview": "pnpm run cloudflare:build:worker && wrangler dev",
27-
"cloudflare:deploy": "pnpm run cloudflare:build:worker && wrangler deploy"
25+
"cloudflare:preview": "wrangler dev",
26+
"cloudflare:deploy": "wrangler deploy"
2827
},
2928
"dependencies": {
3029
"@heroicons/react": "~2.2.0",

apps/site/turbo.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"globalEnv": ["NODE_ENV"],
55
"tasks": {
66
"dev": {
7+
"dependsOn": ["build-blog-data"],
78
"cache": false,
89
"persistent": true,
910
"env": [
@@ -24,7 +25,7 @@
2425
]
2526
},
2627
"build": {
27-
"dependsOn": ["^build"],
28+
"dependsOn": ["build-blog-data", "^build"],
2829
"inputs": [
2930
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx}",
3031
"{app,components,layouts,pages,styles}/**/*.css",
@@ -133,7 +134,19 @@
133134
"inputs": ["{pages}/**/*.{mdx,md}"],
134135
"outputs": ["public/blog-data.json"]
135136
},
137+
"cloudflare:build:worker": {
138+
"dependsOn": ["build-blog-data"],
139+
"inputs": [
140+
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx}",
141+
"{app,components,layouts,pages,styles}/**/*.css",
142+
"{next-data,scripts,i18n}/**/*.{mjs,json}",
143+
"{app,pages}/**/*.{mdx,md}",
144+
"*.{md,mdx,json,ts,tsx,mjs,yml}"
145+
],
146+
"outputs": [".open-next/**"]
147+
},
136148
"cloudflare:preview": {
149+
"dependsOn": ["cloudflare:build:worker"],
137150
"inputs": [
138151
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx}",
139152
"{app,components,layouts,pages,styles}/**/*.css",
@@ -144,6 +157,7 @@
144157
"outputs": [".open-next/**"]
145158
},
146159
"cloudflare:deploy": {
160+
"dependsOn": ["cloudflare:build:worker"],
147161
"inputs": [
148162
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx}",
149163
"{app,components,layouts,pages,styles}/**/*.css",

0 commit comments

Comments
 (0)