now*_*wox 6 github github-actions
我想设置我的工作流程以执行以下操作:
在我.github/workflows的on指令中适用于所有工作,所以它在我的情况下不起作用。另一方面,action/upload-artifact仅在同一工作流程中有效。
实现所描述的工作流程的正确方法是什么?
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
with:
submodules: true
- name: Build
run: make all
- uses: actions/upload-artifact@v2
with:
name: build
path: dist/
- name: Deploy to GitHub Pages
filters: # <-----<<<< What I would like to do
branch: master
uses: JamesIves/github-pages-deploy-action@3.5.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: dist/html
Run Code Online (Sandbox Code Playgroud)
您可以向您的步骤添加条件,只需跳过不需要的部分,请参阅jobs.<id>.steps.if。至于检查什么,github上下文是与当前运行的工作流相关的各种数据的金矿。例如
github.event_name string The name of the event that triggered the workflow run.
github.ref string The branch or tag ref that triggered the workflow run.
github.head_ref string The head_ref or source branch of the pull request in a workflow run.
Run Code Online (Sandbox Code Playgroud)
等等。
请注意,文档中提到的部分只是冰山一角;github.event包含有用的东西墙。最好查看一些测试工作流程,看看每个事件提供了什么。
这样的事情应该工作:
github.event_name string The name of the event that triggered the workflow run.
github.ref string The branch or tag ref that triggered the workflow run.
github.head_ref string The head_ref or source branch of the pull request in a workflow run.
Run Code Online (Sandbox Code Playgroud)
- name: On any event (pull-request, push on any branches)
uses: some/action
Run Code Online (Sandbox Code Playgroud)
- name: Only when master is pushed
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: some/action
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1975 次 |
| 最近记录: |