55name : Deploy Next.js site to Pages
66
77on :
8- # Runs on pushes targeting the default branch
8+ # Runs on pushes targeting the default branch, and dev branches
99 push :
10- branches : ["main"]
10+ branches : ["main", "dev/**"] # dev/* のブランチにも反応するように変更
1111
1212 # Allows you to run this workflow manually from the Actions tab
1313 workflow_dispatch :
@@ -25,7 +25,7 @@ concurrency:
2525 cancel-in-progress : false
2626
2727jobs :
28- # Build job
28+ # Build/Lint job
2929 build :
3030 runs-on : ubuntu-latest
3131 steps :
@@ -39,20 +39,23 @@ jobs:
3939 echo "manager=bun" >> $GITHUB_OUTPUT
4040 echo "command=install" >> $GITHUB_OUTPUT
4141 echo "runner=bun" >> $GITHUB_OUTPUT
42-
42+
4343 - name : Setup Bun
4444 # Bunをインストールするための専用アクション
4545 uses : oven-sh/setup-bun@v1
4646 with :
4747 bun-version : latest # または '1.1.0' のような特定のバージョンを指定
4848
49+ # mainブランチでのみPagesの設定とNext.jsの設定を適用
4950 - name : Setup Pages
51+ if : github.ref == 'refs/heads/main'
5052 uses : actions/configure-pages@v5
5153 with :
5254 # Automatically inject basePath in your Next.js configuration file and disable
5355 # server side image optimization.
5456 static_site_generator : next
5557
58+ # キャッシュの復元(main/devのいずれでも依存関係のインストール前に実行)
5659 - name : Restore cache
5760 uses : actions/cache@v4
5861 with :
@@ -67,18 +70,32 @@ jobs:
6770 - name : Install dependencies
6871 # 'bun install' を実行
6972 run : ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
70-
71- - name : Build with Next.js
73+
74+ # === 処理分岐 ===
75+
76+ - name : Run lint for dev branches
77+ # ブランチ名が 'dev/' で始まる場合にのみ実行
78+ if : startsWith(github.ref, 'refs/heads/dev/')
79+ # lintコマンドを実行
80+ run : ${{ steps.detect-package-manager.outputs.runner }} run lint
81+
82+ - name : Build with Next.js (for main branch)
83+ # mainブランチの場合にのみ実行
84+ if : github.ref == 'refs/heads/main'
7285 # 'bun next build' を実行
7386 run : ${{ steps.detect-package-manager.outputs.runner }} next build
74-
75- - name : Upload artifact
87+
88+ - name : Upload artifact (for main branch)
89+ # mainブランチの場合にのみ実行
90+ if : github.ref == 'refs/heads/main'
7691 uses : actions/upload-pages-artifact@v3
7792 with :
7893 path : ./out
7994
8095 # Deployment job
8196 deploy :
97+ # mainブランチの場合にのみ実行
98+ if : github.ref == 'refs/heads/main'
8299 environment :
83100 name : github-pages
84101 url : ${{ steps.deployment.outputs.page_url }}
87104 steps :
88105 - name : Deploy to GitHub Pages
89106 id : deployment
90- uses : actions/deploy-pages@v4
107+ uses : actions/deploy-pages@v4
0 commit comments