Skip to content
本页目录

自动化打包、部署

vuepress 自动发布

github actions.github/workflows/master.yml:

name: Build  to GitHub Pages
on:
  push:
    branches: [ master ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
    
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '14.x'

    # Caching dependencies to speed up workflows. (GitHub will remove any cache entries that have not been accessed in over 7 days.)
    - name: Cache node modules
      uses: actions/cache@v1
      id: cache
      with:
        path: node_modules
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-node-
    - name: Install Dependencies
      if: steps.cache.outputs.cache-hit != 'true'
      run: npm i

    # Vuepress Build.
    - name: Generates Pages
      run: |
        npm run build

    - name: Deploy Github Pages🚀
      uses: JamesIves/github-pages-deploy-action@4.1.0
      with:
        repository-name: idxiu/xxx # 操作应部署到的分支。.
        branch: master
        folder: ./src/.vuepress/dist # 操作应部署的文件夹.
        ssh-key: ${{ secrets.DEPLOY_KEY }} # 部署密钥

TIP

A仓库 部署到 B仓库

  • B仓库添加DEPLOY_KEY中的公钥
  • A仓库中添加私钥
自动化打包、部署已经加载完毕