name: Build Production

on:
  push:
    branches:
      - master

jobs:
  build:
    # 使用最新版ubantu虚拟机运行
    runs-on: ubuntu-latest

    steps:
      # from: https://github.com/actions/checkout
      - name: 本工作流
        uses: actions/checkout@master

      # 安装最新版 Node.js
      # from: https://github.com/actions/setup-node
      - name: 安装 Node.js
        uses: actions/setup-node@master
        with:
          node-version: 14
          registry-url: https://registry.npmjs.org/

      - name: 安装 yarn
        run: |
          npm install yarn -g
      - name: 安装项目依赖
        run: |
          yarn install
      - name: 构建项目
        run: |
          yarn build
      - name: 部署到 GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: dist
          publish_dir: ./public
