1- # Sample workflow for building and deploying a Next.js site to GitHub Pages
2- #
3- # To get started with Next.js see: https://nextjs.org/docs/getting-started
4- #
5- name : Deploying Static Side With Bun And NextJS
1+ name : Build & Deploy
62
73on :
8- # Runs on pushes targeting the default branch
94 push :
105 branches : ["main"]
116 pull_request :
127 branches : ["main"]
13-
14- # Allows you to run this workflow manually from the Actions tab
158 workflow_dispatch :
169
17- # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1810permissions :
1911 contents : read
2012 pages : write
2113 id-token : write
2214
23- # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
24- # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2515concurrency :
2616 group : " pages"
2717 cancel-in-progress : false
2818
2919jobs :
30- # Build job
20+ # Build job — runs on both push and PR
3121 build :
3222 runs-on : ubuntu-latest
3323 steps :
3424 - name : Checkout
3525 uses : actions/checkout@v4
3626 - name : Setup Bun
3727 uses : oven-sh/setup-bun@v2
38- - name : Setup Pages
39- uses : actions/configure-pages@v5
4028 - name : Restore cache
4129 uses : actions/cache@v4
4230 with :
4331 path : |
4432 .next/cache
45- # Generate a new cache whenever packages or source files change.
4633 key : ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
47- # If source files changed but packages didn't, rebuild from a prior cache.
4834 restore-keys : |
4935 ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
5036 - name : Install dependencies
@@ -59,13 +45,19 @@ jobs:
5945 NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID : ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}
6046 NEXT_PUBLIC_FIREBASE_APP_ID : ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
6147 NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID : ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
48+ # Only upload artifact for deployment on push to main
49+ - name : Setup Pages
50+ if : github.event_name == 'push'
51+ uses : actions/configure-pages@v5
6252 - name : Upload artifact
53+ if : github.event_name == 'push'
6354 uses : actions/upload-pages-artifact@v3
6455 with :
6556 path : ./out
6657
67- # Deployment job
58+ # Deploy job — only runs on push to main, skipped for PRs
6859 deploy :
60+ if : github.event_name == 'push'
6961 environment :
7062 name : github-pages
7163 url : ${{ steps.deployment.outputs.page_url }}
0 commit comments