Skip to content

Commit 05f28bb

Browse files
committed
ci: add Next.js build cache and make static build remove paths configurable
1 parent 3b45412 commit 05f28bb

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/nextjs-static-gh-pages.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,24 @@ jobs:
9292
node-version: '24'
9393
cache: ${{ steps.detect-pm.outputs.manager }}
9494

95+
- name: 📦 Cache Next.js build
96+
uses: actions/cache@v4
97+
with:
98+
path: |
99+
${{ github.workspace }}/.next/cache
100+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
101+
restore-keys: |
102+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
103+
95104
- name: 🚫 Ephemerally delete server/api files
105+
env:
106+
STATIC_BUILD_REMOVE_PATHS: ${{ vars.STATIC_BUILD_REMOVE_PATHS }}
96107
run: |
108+
DEFAULT_PATHS="'src/app/blog/[slug]' 'src/app/invoice/[id]' src/app/api src/server src/proxy.ts 'src/app/jobs/[id]' 'src/app/[...not-found]' prisma.config.ts"
109+
PATHS="${STATIC_BUILD_REMOVE_PATHS:-$DEFAULT_PATHS}"
97110
echo "Deleting server/api files for static build..."
98-
rm -rf src/app/blog/[slug], src/app/invoice/[id] src/app/api src/server src/proxy.ts src/app/jobs/[id] src/app/[...not-found] prisma.config.ts
111+
echo "Paths: $PATHS"
112+
eval rm -rf $PATHS
99113
100114
- name: 📥 Install dependencies
101115
run: ${{ steps.detect-pm.outputs.manager }} ${{ steps.detect-pm.outputs.command }}

0 commit comments

Comments
 (0)