Raj*_*ary 8 github github-actions
我想传递一些动态参数并手动调用我的 GitHub 操作工作流(最好通过一些 API)。这可能吗?
使用workflow_dispatch事件触发器,您可以轻松地进行手动触发。
流动:
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'
Run Code Online (Sandbox Code Playgroud)
博文公告参考,https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
我认为正确的答案是使用repository_dispatchNOT a workflow_dispatch。
只有存储库调度允许您从 API 调用触发工作流。
概括:
https://api.github.com/repos/{owner}/{repo}/dispatches
Run Code Online (Sandbox Code Playgroud)
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "authorization: Bearer <token>" https://api.github.com/repos/{owner}/{repo}/dispatches -d '{"event_type": "type1","client_payload": {"key1": "Hello from CRUD"}}'
Run Code Online (Sandbox Code Playgroud)
要触发via API,可以在https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-eventworkflow_dispatch找到文档
POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches
其中{workflow_id}也可以是工作流程的文件名(这使事情变得更容易)。
curl文档中的示例:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/actions/workflows/42/dispatches \
-d '{"ref":"ref"}'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6068 次 |
| 最近记录: |