Skip to content

Commit ba5d8d0

Browse files
authored
Merge pull request #36 from zecdev/ci-improvements
Add PR CI to verify the site builds before merge
2 parents b7c5579 + ed43a57 commit ba5d8d0

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
3+
# Verify the site builds and produces a publishable static export before a
4+
# branch can be merged into main. Mark the "build" job as a required status
5+
# check in branch protection so PRs cannot merge unless this passes.
6+
on:
7+
pull_request:
8+
branches: ["main"]
9+
# Also run inside a merge queue if one is ever enabled.
10+
merge_group:
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
# Cancel superseded runs for the same PR/ref to save CI minutes.
17+
concurrency:
18+
group: "ci-${{ github.workflow }}-${{ github.ref }}"
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
name: Build (verify publishable export)
24+
runs-on: ubuntu-latest
25+
env:
26+
NEXT_TELEMETRY_DISABLED: 1
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
# pnpm version comes from the "packageManager" field in package.json.
32+
- name: Setup pnpm
33+
uses: pnpm/action-setup@v4
34+
35+
- name: Setup Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: "24"
39+
cache: "pnpm"
40+
41+
- name: Restore Next.js cache
42+
uses: actions/cache@v4
43+
with:
44+
path: |
45+
.next/cache
46+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx', '**/*.mdx') }}
47+
restore-keys: |
48+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
49+
50+
# --frozen-lockfile mirrors the deploy workflow: fails if package.json and
51+
# pnpm-lock.yaml disagree, so a stale lockfile is caught before merge.
52+
- name: Install dependencies
53+
run: pnpm install --frozen-lockfile
54+
55+
- name: Build with Next.js
56+
run: pnpm run build
57+
58+
# next.config sets output: 'export', so a successful build must emit ./out.
59+
# Assert the publishable output exists rather than trusting the exit code alone.
60+
- name: Verify static export was produced
61+
run: |
62+
test -f out/index.html || { echo "::error::out/index.html missing — static export did not build"; exit 1; }
63+
echo "Static export OK: $(find out -name '*.html' | wc -l | tr -d ' ') HTML pages generated."

0 commit comments

Comments
 (0)