|
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: Deploy Next.js site to Pages |
| 1 | +name: Deploy to GitHub Pages |
6 | 2 |
|
7 | 3 | on: |
8 | | - # Runs on pushes targeting the default branch |
9 | 4 | push: |
10 | | - branches: ["main"] |
11 | | - |
12 | | - # Allows you to run this workflow manually from the Actions tab |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
13 | 8 | workflow_dispatch: |
14 | 9 |
|
15 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
16 | 10 | permissions: |
17 | 11 | contents: read |
18 | 12 | pages: write |
19 | 13 | id-token: write |
20 | 14 |
|
21 | | -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
22 | | -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
23 | 15 | concurrency: |
24 | 16 | group: "pages" |
25 | 17 | cancel-in-progress: false |
26 | 18 |
|
27 | 19 | jobs: |
28 | | - # Build job |
29 | 20 | build: |
30 | 21 | runs-on: ubuntu-latest |
31 | 22 | steps: |
32 | 23 | - name: Checkout |
33 | 24 | uses: actions/checkout@v4 |
34 | | - - name: Detect package manager |
35 | | - id: detect-package-manager |
36 | | - 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 |
| 25 | + |
| 26 | + - name: Setup Bun |
| 27 | + uses: oven-sh/setup-bun@v2 |
| 28 | + with: |
| 29 | + bun-version: latest |
| 30 | + |
| 31 | + - name: Setup Node.js |
52 | 32 | uses: actions/setup-node@v4 |
53 | 33 | with: |
54 | | - node-version: "20" |
55 | | - cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 34 | + node-version: '20' |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: bun install --frozen-lockfile |
| 38 | + |
| 39 | + - name: Build |
| 40 | + env: |
| 41 | + NEXT_PUBLIC_BASE_PATH: /website |
| 42 | + run: bun run build |
| 43 | + |
| 44 | + - name: Create .nojekyll file |
| 45 | + run: touch ./out/.nojekyll |
| 46 | + |
56 | 47 | - name: Setup Pages |
57 | 48 | uses: actions/configure-pages@v5 |
58 | | - with: |
59 | | - # 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. |
63 | | - static_site_generator: next |
64 | | - - name: Restore cache |
65 | | - uses: actions/cache@v4 |
66 | | - with: |
67 | | - path: | |
68 | | - .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') }} |
71 | | - # If source files changed but packages didn't, rebuild from a prior cache. |
72 | | - restore-keys: | |
73 | | - ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- |
74 | | - - name: Install dependencies |
75 | | - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
76 | | - - name: Build with Next.js |
77 | | - run: ${{ steps.detect-package-manager.outputs.runner }} next build |
| 49 | + |
78 | 50 | - name: Upload artifact |
79 | 51 | uses: actions/upload-pages-artifact@v3 |
80 | 52 | with: |
81 | 53 | path: ./out |
82 | 54 |
|
83 | | - # Deployment job |
84 | 55 | deploy: |
85 | 56 | environment: |
86 | 57 | name: github-pages |
|
91 | 62 | - name: Deploy to GitHub Pages |
92 | 63 | id: deployment |
93 | 64 | uses: actions/deploy-pages@v4 |
| 65 | + |
0 commit comments