|
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 | 1 | name: Deploy Next.js site to Pages |
6 | 2 |
|
7 | 3 | on: |
8 | | - # Runs on pushes targeting the default branch |
9 | 4 | push: |
10 | 5 | branches: ["main"] |
11 | | - |
12 | | - # Allows you to run this workflow manually from the Actions tab |
13 | 6 | workflow_dispatch: |
14 | 7 |
|
15 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
16 | 8 | permissions: |
17 | 9 | contents: read |
18 | 10 | pages: write |
19 | 11 | id-token: write |
20 | 12 |
|
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 | 13 | concurrency: |
24 | 14 | group: "pages" |
25 | 15 | cancel-in-progress: false |
26 | 16 |
|
27 | 17 | jobs: |
28 | | - # Build job |
29 | 18 | build: |
30 | 19 | runs-on: ubuntu-latest |
31 | 20 | steps: |
@@ -56,31 +45,27 @@ jobs: |
56 | 45 | - name: Setup Pages |
57 | 46 | uses: actions/configure-pages@v5 |
58 | 47 | 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 | 48 | static_site_generator: next |
64 | 49 | - name: Restore cache |
65 | 50 | uses: actions/cache@v4 |
66 | 51 | with: |
67 | 52 | path: | |
68 | 53 | .next/cache |
69 | | - # Generate a new cache whenever packages or source files change. |
70 | 54 | 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 | 55 | restore-keys: | |
73 | 56 | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- |
74 | 57 | - name: Install dependencies |
75 | 58 | run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
76 | 59 | - name: Build with Next.js |
| 60 | + env: |
| 61 | + NEXT_PUBLIC_BASE_PATH: /${{ github.event.repository.name }} |
| 62 | + NODE_ENV: production |
77 | 63 | run: ${{ steps.detect-package-manager.outputs.runner }} next build |
78 | 64 | - name: Upload artifact |
79 | 65 | uses: actions/upload-pages-artifact@v3 |
80 | 66 | with: |
81 | 67 | path: ./out |
82 | 68 |
|
83 | | - # Deployment job |
84 | 69 | deploy: |
85 | 70 | environment: |
86 | 71 | name: github-pages |
|
0 commit comments