Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Build with ncc
- name: Build with esbuild
run: |
npm install
npm run build
Expand All @@ -34,19 +34,5 @@ jobs:
- name: Invoke echo 1 workflow by id
uses: ./
with:
workflow: "1854247"
workflow: '1854247'
inputs: '{"message": "Mango jam"}'

# - name: Push dist back to GitHub
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}

# - name: Invoke external workflow using this action
# uses: ./
# with:
# workflow: Deploy To Kubernetes
# repo: benc-uk/dapr-store
# token: ${{ secrets.PERSONAL_TOKEN }}
# ref: master
12 changes: 7 additions & 5 deletions .github/workflows/echo-2.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: Message Echo 2

on:
on:
workflow_dispatch:
inputs:
message:
description: "Message to echo"
description: 'Message to echo'
required: false
default: "this is echo 2"
default: 'this is echo 2'

jobs:
echo:
runs-on: ubuntu-latest
steps:
- name: Echo message
run: echo '${{ inputs.message }}'
- name: Echo message slowly with a wait
run: |
sleep 125
echo '${{ inputs.message }}'
26 changes: 14 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
name: Workflow Tester

on:
on:
workflow_dispatch:

jobs:
testAction:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Invoke echo 1
uses: ./
with:
workflow: echo-1.yaml
inputs: '{"message": "blah blah this is a test"}'
- name: Invoke echo 2
uses: ./
with:
workflow: Message Echo 2
inputs: '{"message": "mushrooms in the morning"}'
- uses: actions/checkout@v6
- name: Invoke echo 1
uses: ./
with:
workflow: echo-1.yaml
inputs: '{"message": "blah blah this is a test"}'
- name: Invoke echo 2
uses: ./
with:
workflow: Message Echo 2
inputs: '{"message": "mushrooms in the morning"}'
wait-for-completion: true
wait-timeout-seconds: 26
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.format.enable": true,
"[typescript]": {
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright 2020 Ben Coleman
Copyright 2026 Ben Coleman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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.

**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!

![Screenshot the logs of a workflow run](./etc/screen.png)

For details of the `workflow_dispatch` even see [this blog post introducing this type of trigger](https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/)

_Note 1._ GitHub now has a native way to chain workflows called "reusable workflows". See the docs on [reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows). This approach is somewhat different from workflow_dispatch but it's worth keeping in mind.
Expand Down Expand Up @@ -50,9 +54,22 @@ workflow: 1218419

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. 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).

## Action Outputs

This Action emits a single output named `workflowId`.
| 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

Expand All @@ -64,11 +81,12 @@ This Action emits a single output named `workflowId`.
```

```yaml
- name: Invoke workflow with inputs
- 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
Expand All @@ -79,5 +97,5 @@ This Action emits a single output named `workflowId`.
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 }}"
token: '${{ secrets.MY_TOKEN }}'
```
36 changes: 27 additions & 9 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
name: "Workflow Dispatch"
description: "Trigger and chain GitHub Actions workflows with workflow_dispatch events"
name: 'Workflow Dispatch'
description: 'Trigger and chain GitHub Actions workflows with workflow_dispatch events'

inputs:
workflow:
description: "Name, filename or ID of workflow to run"
description: 'Name, filename or ID of workflow to run'
required: true
token:
description: "GitHub token with repo write access, only required if the workflow is in a different repository"
description: 'GitHub token with repo write access, only required if the workflow is in a different repository'
required: false
default: ${{ github.token }}
inputs:
description: "Inputs to pass to the workflow, must be a JSON string"
description: 'Inputs to pass to the workflow, must be a JSON string'
required: false
ref:
description: "The reference can be a branch, tag, or a commit SHA"
description: 'The reference can be a branch, tag, or a commit SHA'
required: false
repo:
description: "Repo owner & name, slash separated, only set if invoking a workflow in a different repo"
description: 'Repo owner & name, slash separated, only set if invoking a workflow in a different repo'
required: false
wait-for-completion:
description: 'Whether to wait for the workflow run to complete before finishing this action'
required: false
default: false
wait-timeout-seconds:
description: 'Maximum time in seconds to wait for the workflow run to complete before timing out (only applies if wait-for-completion is true)'
required: false
default: 900

outputs:
runId:
description: 'The ID of the workflow run that was triggered'
runUrl:
description: 'The API URL of the workflow run that was triggered'
runUrlHtml:
description: 'The HTML URL of the workflow run that was triggered'
workflowId:
description: 'The ID of the workflow that was triggered'

runs:
using: "node20"
main: "dist/index.js"
using: 'node24'
main: 'dist/index.js'

branding:
color: purple
Expand Down
Loading