Skip to content

Commit 582f594

Browse files
committed
GitHub Pagesのデプロイ設定を追加
1 parent 9856416 commit 582f594

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

.github/workflows/pages.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# GitHub Pages へデプロイするためのシンプルなワークフロー
2+
name: Deploy Next.js site to Pages
3+
4+
on:
5+
# `main` ブランチに変更がプッシュされたときに実行されます
6+
push:
7+
branches: ["main"]
8+
9+
# Actions タブから手動でワークフローを実行できるようにします
10+
workflow_dispatch:
11+
12+
# GITHUB_TOKEN の権限を設定し、GitHub Pages へのデプロイを許可します
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# 複数のジョブをシーケンシャルに実行することを許可します
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: true
22+
23+
jobs:
24+
# ビルドジョブ
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
- name: Setup Node
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "20"
34+
cache: "npm"
35+
- name: Setup Pages
36+
uses: actions/configure-pages@v5
37+
- name: Install dependencies
38+
run: npm install
39+
- name: Build with Next.js
40+
run: next build
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
# out ディレクトリをアップロードします
45+
path: "./out"
46+
47+
# デプロイジョブ
48+
deploy:
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
runs-on: ubuntu-latest
53+
needs: build
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

next.config.ts

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

3+
const isProd = process.env.NODE_ENV === "production";
4+
35
const nextConfig: NextConfig = {
6+
output: "export",
7+
basePath: isProd ? "/knowledge-ec" : "",
48
/* config options here */
59
images: {
610
remotePatterns: [
@@ -13,7 +17,8 @@ const nextConfig: NextConfig = {
1317
hostname: "avatars.githubusercontent.com",
1418
},
1519
],
20+
unoptimized: true,
1621
},
1722
};
1823

19-
export default nextConfig;
24+
export default nextConfig;

0 commit comments

Comments
 (0)