|
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 Zen Docs |
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 |
| 20 | + |
31 | 21 | steps: |
32 | | - - name: Checkout |
| 22 | + - name: Checkout repository |
33 | 23 | uses: actions/checkout@v4 |
34 | | - - name: Detect package manager |
35 | | - id: detect-package-manager |
36 | | - run: | |
37 | | - if [ -f "${{ github.workspace }}/package.json" ]; then |
38 | | - echo "manager=npm" >> $GITHUB_OUTPUT |
39 | | - echo "command=install" >> $GITHUB_OUTPUT |
40 | | - echo "runner=npx --no-install" >> $GITHUB_OUTPUT |
41 | | - exit 0 |
42 | | - else |
43 | | - echo "Unable to determine package manager" |
44 | | - exit 1 |
45 | | - fi |
46 | | - - name: Setup Node |
| 24 | + |
| 25 | + - name: Setup Node.js |
47 | 26 | uses: actions/setup-node@v4 |
48 | 27 | with: |
49 | | - node-version: "20" |
50 | | - cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 28 | + node-version: "22" |
| 29 | + cache: "npm" |
51 | 30 | cache-dependency-path: "package.json" |
52 | 31 | check-latest: true |
53 | | - - name: Setup Pages |
| 32 | + |
| 33 | + - name: Setup GitHub Pages |
54 | 34 | uses: actions/configure-pages@v5 |
55 | | - # with: |
56 | | - # Automatically inject basePath in your Next.js configuration file and disable |
57 | | - # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). |
58 | | - # |
59 | | - # You may remove this line if you want to manage the configuration yourself. |
60 | | - # static_site_generator: next |
| 35 | + |
61 | 36 | - name: Restore cache |
62 | 37 | uses: actions/cache@v4 |
63 | 38 | with: |
64 | 39 | path: | |
65 | 40 | .next/cache |
66 | 41 | node_modules |
67 | | - # Generate a new cache whenever packages or source files change. |
68 | 42 | key: ${{ runner.os }}-nextjs-${{ hashFiles('package.json') }} |
69 | | - # If source files changed but packages didn't, rebuild from a prior cache. |
70 | 43 | restore-keys: | |
71 | 44 | ${{ runner.os }}-nextjs- |
| 45 | +
|
72 | 46 | - name: Install dependencies |
73 | | - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
| 47 | + run: npm install |
| 48 | + |
74 | 49 | - name: Build with Next.js |
75 | | - run: ${{ steps.detect-package-manager.outputs.runner }} next build |
| 50 | + run: npx --no-install next build |
| 51 | + |
76 | 52 | - name: Upload artifact |
77 | 53 | uses: actions/upload-pages-artifact@v3 |
78 | 54 | with: |
79 | 55 | path: ./out |
80 | 56 |
|
81 | | - # Deployment job |
82 | 57 | deploy: |
83 | 58 | environment: |
84 | 59 | name: github-pages |
85 | 60 | url: ${{ steps.deployment.outputs.page_url }} |
86 | 61 | runs-on: ubuntu-latest |
87 | 62 | needs: build |
| 63 | + |
88 | 64 | steps: |
89 | 65 | - name: Deploy to GitHub Pages |
90 | 66 | id: deployment |
|
0 commit comments