1- # Sample workflow for building and deploying a Next.js site to GitHub Pages
1+ # Sample workflow for building and deploying a Next.js site to GitHub Pages using Bun
22#
33# To get started with Next.js see: https://nextjs.org/docs/getting-started
44#
@@ -31,50 +31,47 @@ jobs:
3131 steps :
3232 - name : Checkout
3333 uses : actions/checkout@v4
34+
3435 - name : Detect package manager
36+ # Bunを使用するようにマネージャー情報を固定
3537 id : detect-package-manager
3638 run : |
37- if [ -f "${{ github.workspace }}/yarn.lock" ]; then
38- echo "manager=yarn" >> $GITHUB_OUTPUT
39- echo "command=install" >> $GITHUB_OUTPUT
40- echo "runner=yarn" >> $GITHUB_OUTPUT
41- exit 0
42- elif [ -f "${{ github.workspace }}/package.json" ]; then
43- echo "manager=npm" >> $GITHUB_OUTPUT
44- echo "command=ci" >> $GITHUB_OUTPUT
45- echo "runner=npx --no-install" >> $GITHUB_OUTPUT
46- exit 0
47- else
48- echo "Unable to determine package manager"
49- exit 1
50- fi
51- - name : Setup Node
52- uses : actions/setup-node@v4
39+ echo "manager=bun" >> $GITHUB_OUTPUT
40+ echo "command=install" >> $GITHUB_OUTPUT
41+ echo "runner=bun" >> $GITHUB_OUTPUT
42+
43+ - name : Setup Bun
44+ # Bunをインストールするための専用アクション
45+ uses : oven-sh/setup-bun@v1
5346 with :
54- node -version : " 20 "
55- cache : ${{ steps.detect-package-manager.outputs.manager }}
47+ bun -version : latest # または '1.1.0' のような特定のバージョンを指定
48+
5649 - name : Setup Pages
5750 uses : actions/configure-pages@v5
5851 with :
5952 # Automatically inject basePath in your Next.js configuration file and disable
60- # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
61- #
62- # You may remove this line if you want to manage the configuration yourself.
53+ # server side image optimization.
6354 static_site_generator : next
55+
6456 - name : Restore cache
6557 uses : actions/cache@v4
6658 with :
6759 path : |
6860 .next/cache
69- # Generate a new cache whenever packages or source files change.
70- key : ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn .lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
61+ # bun.lockbをキャッシュキーに使用
62+ key : ${{ runner.os }}-nextjs-${{ hashFiles('**/bun .lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
7163 # If source files changed but packages didn't, rebuild from a prior cache.
7264 restore-keys : |
73- ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
65+ ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock') }}-
66+
7467 - name : Install dependencies
68+ # 'bun install' を実行
7569 run : ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
70+
7671 - name : Build with Next.js
72+ # 'bun next build' を実行
7773 run : ${{ steps.detect-package-manager.outputs.runner }} next build
74+
7875 - name : Upload artifact
7976 uses : actions/upload-pages-artifact@v3
8077 with :
9087 steps :
9188 - name : Deploy to GitHub Pages
9289 id : deployment
93- uses : actions/deploy-pages@v4
90+ uses : actions/deploy-pages@v4
0 commit comments