百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

workflow-dispatch

> DevOps
开源

一个 GitHub 操作,用于触发工作流,使用 `workflow_dispatch` 事件

389 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个 GitHub 操作,用于触发工作流,使用 `workflow_dispatch` 事件

GitHub Action for Dispatching Workflows

This action triggers another GitHub Actions workflow, using the workflow_dispatch event. The workflow must be configured for this event type e.g. on: [workflow_dispatch]

This allows you to chain workflows, the classic use case is have a CI build workflow, trigger a CD release/deploy workflow when it completes. Allowing you to maintain separate workflows for CI and CD, and pass data between them as required.

For details of the workflow_dispatch even see this blog post introducing this type of trigger

Note, GitHub now has a native way to chain workflows called "reusable workflows". See the docs on reusing workflows. This approach is somewhat different from workflow_dispatch but it's worth keeping in mind.

The GitHub UI will report flows triggered by this action as "manually triggered" this might seem confusing at first, but it makes sense when you remember that the workflow_dispatch event is designed to be triggered manually by a user, and this action is simulating that manual trigger.

2026 Update

We finally have a way to get the details of the triggered workflow run, including the run ID and URL, which means we can now poll for the run status and wait for it to complete if required. This is a common ask and I'm glad to have added this feature after nearly 6 years!

Action Inputs

workflow

Required. The name, filename or ID of the workflow to be triggered and run. All three possibilities are used when looking for the workflow. e.g.

yaml
workflow: My Workflow
# or
workflow: my-workflow.yaml
# or
workflow: 1218419

Note: If you want to reference the target workflow by ID, you will need to list the IDs with a REST API call curl https://api.github.com/repos/{{owner}}/{{repo}}/actions/workflows -H "Authorization: token {{pat-token}}"

inputs

Optional. The inputs to pass to the workflow (if any are configured), this must be a JSON encoded string, e.g. { "myInput": "foobar" }

ref

Optional. The Git reference used with the triggered workflow run. The reference can be a branch, tag, or a commit SHA. If omitted the context ref of the triggering workflow is used. If you want to trigger on pull requests and run the target workflow in the context of the pull request branch, set the ref to ${{ github.event.pull_request.head.ref }}.

repo

Optional. The default behavior is to trigger workflows in the same repo as the triggering workflow, if you wish to trigger in another GitHub repo "externally", then provide the owner + repo name with slash between them e.g. microsoft/vscode.

  • When triggering across repos like this, you must provide a token (see below), or you will get an "Resource not accessible by integration" error.
  • If the default branch in the other repo is different from the calling repo, you must provide ref input also, or you will get a "No ref found" error.

token

Optional. By default the standard github.token/GITHUB_TOKEN will be used and you no longer need to provide your own token here.

⚠️ IMPORTANT: When using the repo option to call across repos, you must provide the token. In order to do so, create a PAT token with repo rights, and pass it here via a secret, e.g. ${{ secrets.MY_TOKEN }}.

This option is also left for backwards compatibility with older versions where this field was mandatory.

wait-for-completion

Optional. Set to 'true' to wait for the triggered workflow run to complete before finishing this action. The action will poll the run status every 5 seconds, but you can change this by setting wait-interval-seconds. Default is false.

wait-timeout-seconds

Optional. The maximum time in seconds to wait for the triggered workflow run to complete before timing out. This only applies if wait-for-completion is set to true. Default is 900 seconds (15 minutes).

wait-interval-seconds

Optional. Interval in seconds between polls. This only applies if wait-for-completion is set to true. Default is 5 seconds.

sync-status

Optional. Set to 'true' to sync the status of this action with the triggered workflow run. If the triggered workflow run fails or is cancelled, this action will also be set to failed. This only applies if wait-for-completion is set to true. Default is false.

Action Outputs

Output Description
runId The ID of the workflow run that was triggered
runUrl The API URL of the workflow run that was triggered
runUrlHtml The HTML URL of the workflow run that was triggered
workflowId The ID of the workflow that was triggered

Example usage

yaml
- name: Invoke workflow without inputs
  uses: benc-uk/workflow-dispatch@v1
  with:
    workflow: My Workflow
yaml
- name: Invoke workflow with inputs & wait
  uses: benc-uk/workflow-dispatch@v1
  with:
    workflow: Another Workflow
    inputs: '{ "message": "blah blah", "something": true }'
    wait-for-completion: true
yaml
- name: Invoke workflow in another repo with inputs
  uses: benc-uk/workflow-dispatch@v1
  with:
    workflow: my-workflow.yaml
    repo: benc-uk/example
    inputs: '{ "message": "blah blah", "something": false }'
    # Required when using the `repo` option. Either a PAT or a token generated from the GitHub app or CLI
    token: '${{ secrets.MY_TOKEN }}'

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptdevopsgithubgithub-actions

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理