Deploy by @coder-czy #26
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: | |
# clone 该仓库的源码到工作流中 | |
- name: Clone Code | |
uses: actions/checkout@v3 | |
with: | |
# persist-credentials: false | |
# "最近更新时间"等 git 日志相关信息,需要拉取全部提交记录 | |
fetch-depth: 0 | |
# 安装node | |
- name: Setup 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缓存可以减少安装时间 | |
- name: Setup pnpm cache | |
uses: actions/cache@v3 | |
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 | |
# # 如果你的依赖是使用npm的,用这种 | |
# # 缓存 npm node_modules | |
# - name: Cache dependencies | |
# uses: actions/cache@v3 | |
# with: | |
# path: ~/.npm | |
# key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-npm-cache- | |
# # 安装依赖 npm | |
# - name: Install dependencies | |
# # 如果没有命中缓存才执行 npm install | |
# if: steps.cache-deps.outputs.cache-hit != 'true' | |
# run: | | |
# npm install --legacy-peer-deps | |
# npm run build:prod | |
# 部署到gh-pages分支 | |
- name: deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public |