请用一些真实的例子来解释这两种事件触发器的区别。
显然,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