github actions自动构建vite+vue项目并发布
name: build website on: push: branches: - main workflow_dispatch: permissions: write-all jobs: docs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: '14' - name: 缓存依赖 uses: actions/cache@v2 id: yarn-cache with: path: | **/node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - name: 安装依赖 if: steps.yarn-cache.outputs.cache-hit != 'true' run: yarn install --frozen-lockfile - name: 构建 run: yarn build - name: 发布到Github Pages uses: crazy-max/ghaction-github-pages@v2.1.3 with: target_branch: gh-pages build_dir: ./dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}