Skip to content

基于Action自动编译部署官网到github.io #1

@zhaobinglong

Description

@zhaobinglong

参考:http://www.ruanyifeng.com/blog/2019/09/getting-started-with-github-actions.html

监听指定的分支提交

on:
  push:
    branches: [ develop ]

执行多个命令

注意要在run后面加|,表示后面的命令在同一个上下文环境中执行

    - run: |
        npm install 
        npm run build --if-present

部署命令

引用peaceiris/actions-gh-pages@v3,提前添加deploy_key,当监听到develop分支的代码提交后,如果我们想把编译后的文件部署到master分支上,则配置publish_branch为master,publish_dir用来指定想要部署的文件夹

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3
      with:
        deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
        publish_branch: master
        publish_dir: ./.vuepress/dist
        allow_empty_commit: true

Action市场寻找一个action

https://github.com/ + action被引用的名字

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions