繁体   English   中英

Github Actions 中的 repository_dispatch 和 workflow_dispatch 有什么区别?

[英]Whats is the difference between repository_dispatch and workflow_dispatch in Github Actions?

请用一些现实世界的例子解释这两个事件触发器之间的区别。

显然, repository_dispatch事件只能在默认分支上读取

看:

对于后者,来自William Villeneuve

# TODO: replace :token, :user, and :repo
curl -H "Authorization: token :token" \
    -H 'Accept: application/vnd.github.everest-preview+json' \
    "https://api.github.com/repos/:user/:repo/dispatches" \
    -d '{"event_type": "awesomeness", "client_payload": {"foo": "bar"}}'
name: example-client-payload-action
on: repository_dispatch
jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: 'echo "field: ${{ github.event.client_payload.foo }}"'
      - run: 'echo "payload: ${{ toJson(github.event.client_payload) }}"'
      - run: echo baz
        if: github.event.action == 'baz'

如此处所示

只是在这里发布,因为它似乎没有记录 - 您还可以指定要触发的类型列表:

on:
  repository_dispatch:
    types:
      - manual-trigger-mytest
      - manual-trigger-all

来自“ 手动触发 GitHub 操作工作流

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM