-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
3 changed files
with
59 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 检出代码 | ||
uses: actions/checkout@v2 | ||
|
||
- name: 设置 Node.js 版本 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
|
||
- name: 安装 pnpm | ||
run: npm install -g pnpm | ||
|
||
- name: 删除 node_modules 目录 | ||
run: rm -rf node_modules | ||
|
||
- name: 安装依赖 | ||
run: pnpm i | ||
|
||
- name: 项目构建 | ||
run: pnpm run build | ||
|
||
- name: 项目部署 | ||
uses: JamesIves/github-pages-deploy-action@4.1.5 | ||
with: | ||
branch: gh-pages | ||
folder: dist | ||
|
||
- name: 获取版本号 | ||
id: package | ||
run: echo "::set-output name=version::$(node -p "require('./package.json').version")" | ||
|
||
- name: 创建 tag | ||
run: git tag v${{ steps.package.outputs.version }} | ||
# 判断 version 是否已存在 | ||
if: startsWith(github.ref, 'refs/heads/master') && !contains(github.ref, 'refs/tags/v${{ steps.package.outputs.version }}') | ||
|
||
- name: 推送 tag | ||
uses: ad-m/github-push-action@v0.7.0 | ||
if: startsWith(github.ref, 'refs/heads/master') && !contains(github.ref, 'refs/tags/v${{ steps.package.outputs.version }}') | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tags: v${{ steps.package.outputs.version }} | ||
|
||
- name: 发布 Release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
name: v${{ steps.package.outputs.version }} | ||
tag_name: v${{ steps.package.outputs.version }} |
This file was deleted.
Oops, something went wrong.