Skip to content

Commit c75cf16

Browse files
harriiinniiclaude
andcommitted
Add GitHub Pages deployment
- Static export via next.config.ts (output: export) - PAGES_BASE_PATH env var for base path (/docs-hunting for GitHub Pages, empty for custom domain) - GitHub Actions workflow: build on push to main → deploy to Pages - images.unoptimized: true for static export compatibility Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 1bb6a0e commit c75cf16

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: "20"
27+
cache: "npm"
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build
33+
env:
34+
PAGES_BASE_PATH: /docs-hunting
35+
run: npm run build
36+
37+
- name: Upload artifact
38+
uses: actions/upload-pages-artifact@v3
39+
with:
40+
path: ./out
41+
42+
deploy:
43+
needs: build
44+
runs-on: ubuntu-latest
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

next.config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import type { NextConfig } from "next";
22

3+
const isProd = process.env.NODE_ENV === "production";
4+
// When deploying to GitHub Pages as a project repo, set the repo name as base path.
5+
// Remove basePath/assetPrefix when using a custom domain (hunting.0d4y.dev).
6+
const repoName = process.env.PAGES_BASE_PATH ?? "";
7+
38
const nextConfig: NextConfig = {
4-
/* config options here */
9+
output: "export",
10+
basePath: repoName,
11+
assetPrefix: repoName,
12+
images: {
13+
unoptimized: true,
14+
},
15+
trailingSlash: true,
516
};
617

718
export default nextConfig;

0 commit comments

Comments
 (0)