Skip to content

Commit 9a58bb2

Browse files
committed
ci: add Cloudflare Pages static and runtime workflows
1 parent 51e2adf commit 9a58bb2

2 files changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: ☁️ Deploy to Cloudflare Pages (Runtime)
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: cloudflare-pages-runtime-${{ github.ref_name }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
deploy-runtime:
17+
name: 🏗 Build and Deploy Runtime
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: 🔍 Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: ⚙️ Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: 10
28+
29+
- name: ⚙️ Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '24'
33+
cache: 'pnpm'
34+
35+
- name: 📥 Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: 🏗 Build Next.js for runtime
39+
env:
40+
NEXT_OUTPUT_MODE: standalone
41+
run: pnpm build
42+
43+
- name: 🏗 Build Cloudflare Pages output (functions + static)
44+
run: pnpm dlx @cloudflare/next-on-pages@1
45+
46+
- name: 🚀 Deploy runtime app to Cloudflare Pages
47+
uses: cloudflare/wrangler-action@v3
48+
with:
49+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
50+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
51+
command: >-
52+
pages deploy .vercel/output/static
53+
--project-name=${{ secrets.CLOUDFLARE_PAGES_PROJECT_NAME_RUNTIME }}
54+
--branch=${{ github.ref_name }}
55+
--commit-hash=${{ github.sha }}
56+
--functions=.vercel/output/functions
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: ☁️ Deploy to Cloudflare Pages
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: cloudflare-pages-${{ github.ref_name }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
deploy:
17+
name: 🏗 Build and Deploy
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: 🔍 Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: ⚙️ Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: 10
28+
29+
- name: ⚙️ Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '24'
33+
cache: 'pnpm'
34+
35+
- name: 🚫 Remove server-only paths for export build
36+
run: |
37+
echo "Pruning dynamic/server paths not supported by static export..."
38+
rm -rf src/app/api src/server src/proxy.ts src/app/jobs/[id] src/app/[...not-found] prisma.config.ts
39+
40+
- name: 📥 Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
43+
- name: 🏗 Build static export
44+
env:
45+
NEXT_OUTPUT_MODE: export
46+
GITHUB_PAGES: 1
47+
NEXT_BASE_PATH: ''
48+
run: |
49+
pnpm build
50+
51+
- name: 🚀 Deploy to Cloudflare Pages
52+
uses: cloudflare/wrangler-action@v3
53+
with:
54+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
55+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
56+
command: >-
57+
pages deploy out
58+
--project-name=${{ secrets.CLOUDFLARE_PAGES_PROJECT_NAME }}
59+
--branch=${{ github.ref_name }}

0 commit comments

Comments
 (0)