Deploy by @coder-czy #16
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
# 工作流名称 | |
name: Auto Build | |
# 从工作流生成的工作流运行的名称,如果省略,则使用提交时的commit信息 | |
run-name: Deploy by @${{ github.actor }} | |
# 触发条件 | |
on: | |
push: | |
branches: | |
- master | |
# 工作流的步骤 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
# 安装node | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
# 安装pnpm | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 7 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
# 使用pnpm缓存可以减少安装时间 | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
# 安装依赖 | |
- name: Install dependencies and build | |
run: | | |
pnpm install | |
pnpm run build:prod | |
# 部署到gh-pages分支 | |
- name: deploy | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages | |
folder: dist | |
clean: true |