1- name : Docusaurus Build & Deploy
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 to GH Pages
26
37on :
8+ # Runs on pushes targeting the default branch
49 push :
5- branches :
6- - docs
7- # Review gh actions docs if you want to further define triggers, paths, etc
8- # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
10+ branches : ["docs"]
11+
12+ # Allows you to run this workflow manually from the Actions tab
13+ workflow_dispatch :
14+
15+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16+ permissions :
17+ contents : read
18+ pages : write
19+ id-token : write
20+
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+ concurrency :
24+ group : " pages"
25+ cancel-in-progress : false
926
1027jobs :
11- deploy :
12- name : Deploy to GitHub Pages
28+ # Build job
29+ build :
1330 runs-on : ubuntu-latest
1431 steps :
15- - uses : actions/checkout@v3
16- - uses : actions/setup-node@v3
32+ - name : Checkout
33+ uses : actions/checkout@v4
34+ - name : Setup pnpm
35+ uses : pnpm/action-setup@v3
1736 with :
18- node-version : 18
19- cache : npm
20-
37+ version : 9
38+ - name : Detect package manager
39+ id : detect-package-manager
40+ run : |
41+ if [ -f "${{ github.workspace }}/yarn.lock" ]; then
42+ echo "manager=yarn" >> $GITHUB_OUTPUT
43+ echo "command=install" >> $GITHUB_OUTPUT
44+ echo "runner=yarn" >> $GITHUB_OUTPUT
45+ exit 0
46+ elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
47+ echo "manager=pnpm" >> $GITHUB_OUTPUT
48+ echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
49+ echo "runner=npx --no-install" >> $GITHUB_OUTPUT
50+ exit 0
51+ elif [ -f "${{ github.workspace }}/package.json" ]; then
52+ echo "manager=npm" >> $GITHUB_OUTPUT
53+ echo "command=ci" >> $GITHUB_OUTPUT
54+ echo "runner=npx --no-install" >> $GITHUB_OUTPUT
55+ exit 0
56+ else
57+ echo "Unable to determine package manager"
58+ exit 1
59+ fi
60+ - name : Setup Node
61+ uses : actions/setup-node@v4
62+ with :
63+ node-version : " 22"
64+ cache : ${{ steps.detect-package-manager.outputs.manager }}
65+ - name : Setup Pages
66+ uses : actions/configure-pages@v5
67+ with :
68+ # Automatically inject basePath in your Next.js configuration file and disable
69+ # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
70+ #
71+ # You may remove this line if you want to manage the configuration yourself.
72+ static_site_generator : next
73+ - name : Restore cache
74+ uses : actions/cache@v4
75+ with :
76+ path : |
77+ .next/cache
78+ # Generate a new cache whenever packages or source files change.
79+ key : ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
80+ # If source files changed but packages didn't, rebuild from a prior cache.
81+ restore-keys : |
82+ ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-
2183 - name : Install dependencies
22- run : yarn install --frozen-lockfile
23- - name : Build website
24- run : yarn build
84+ run : ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
85+ - name : Build with Next.js
86+ run : ${{ steps.detect-package-manager.outputs.runner }} next build
87+ - name : Upload artifact
88+ uses : actions/upload-pages-artifact@v3
89+ with :
90+ path : ./out
2591
26- # Popular action to deploy to GitHub Pages:
27- # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
92+ # Deployment job
93+ deploy :
94+ environment :
95+ name : github-pages
96+ url : ${{ steps.deployment.outputs.page_url }}
97+ runs-on : ubuntu-latest
98+ needs : build
99+ steps :
28100 - name : Deploy to GitHub Pages
29- uses : peaceiris/actions-gh-pages@v3
30- with :
31- github_token : ${{ secrets.GITHUB_TOKEN }}
32- # Build output to publish to the `gh-pages` branch:
33- publish_dir : ./build
34- # The following lines assign commit authorship to the official
35- # GH-Actions bot for deploys to `gh-pages` branch:
36- # https://github.com/actions/checkout/issues/13#issuecomment-724415212
37- # The GH actions bot is used by default if you didn't specify the two fields.
38- # You can swap them out with your own user credentials.
39- user_name : github-actions[bot]
40- user_email : 41898282+github-actions[bot]@users.noreply.github.com
101+ id : deployment
102+ uses : actions/deploy-pages@v4
0 commit comments