1+ # Simple workflow for deploying static content to GitHub Pages
2+ name : DeployPage
3+
4+ on :
5+ # ###################################################################
6+ # If you want to setup a cron schedule, uncomment the following line
7+ # and set the cron schedule as desired (https://crontab.guru/).
8+ #
9+ # 如果你想要设置一个定时任务,取消下面一行的注释,并设置你想要的定时任务
10+ # 注意:定时任务的时间是 UTC 时间,北京时间需要减去 8 小时
11+
12+ # schedule:
13+ # - cron: '30 4 * * *'
14+
15+
16+ # ###################################################################
17+ # Allows you to run this workflow manually from the Actions tab
18+ #
19+ # 允许你在 Actions 页面手动运行这个工作流
20+ workflow_dispatch :
21+ inputs :
22+ unconditional-invoking :
23+ description : ' Deploy Manually'
24+ type : boolean
25+ required : true
26+ default : true
27+
28+ # ###################################################################
29+ # Allows you to run this workflow manually from the Actions tab
30+ # Runs on pushes targeting the default branch
31+ # If you think you have enough compute times, or if you deploy just ocassionally
32+ # you can uncomment the following line
33+ # 每次推送都自动部署到 GitHub Pages
34+ push :
35+ branches : ["main"]
36+
37+
38+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
39+ permissions :
40+ contents : read
41+ pages : write
42+ id-token : write
43+
44+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
45+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
46+ concurrency :
47+ group : " pages"
48+ cancel-in-progress : false
49+
50+ jobs :
51+ # Single deploy job since we're just deploying
52+ deploy :
53+ environment :
54+ name : github-pages
55+ url : ${{ steps.deployment.outputs.page_url }}
56+ runs-on : ubuntu-latest
57+ steps :
58+ - name : Checkout
59+ uses : actions/checkout@v3
60+ - name : Set up Node.js
61+ uses : actions/setup-node@v2
62+ with :
63+ node-version : ' 18' # 指定所需的 Node.js 版本
64+ # 替换掉docusaurus.config.js中的baseurl
65+ - name : config
66+ run : |
67+ sed -i "s/baseUrl: '\/'/baseUrl: '\/${{ github.event.repository.name }}\/'/g" docusaurus.config.js
68+ - name : Build Page
69+ run : |
70+ npm install
71+ npm run build
72+ - name : Setup Pages
73+ uses : actions/configure-pages@v3
74+ - name : Upload artifact
75+ uses : actions/upload-pages-artifact@v2
76+ with :
77+ # Upload entire repository
78+ path : ' ./build'
79+ - name : Deploy to GitHub Pages
80+ id : deployment
81+ uses : actions/deploy-pages@v2
0 commit comments