-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d884154
commit a3b64a3
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: ci/cd for deployment | ||
|
||
run-name: ${{ github.actor }} are tigger ci/cd action | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
# 必须添加下列权限 | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# 限制并发,当触发新的工作流时,取消之前的工作流 | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repo code | ||
uses: actions/checkout@v4 | ||
- name: set node version | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
- name: Cache node modules | ||
id: cache-npm | ||
# 缓存node_modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: './node_modules' | ||
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | ||
# 命中缓存就跳过安装依赖 | ||
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
name: install dependencies | ||
run: npm install | ||
- name: build project | ||
run: npm run build | ||
- name: upload build file | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
# 指定上传文件夹 | ||
path: './dist' | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: deploy to github pages | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# react-workflow | ||
|
||
构建 react 工作流 | ||
|
||
### 支持 ci/cd 上传构建后页面到 github action | ||
* 需要在仓库中的 settings -> pages 页面,设置 Build and deployment 为 GitHub Actions。 |