Skip to content

Commit a54f9d1

Browse files
authored
2026 refresh (#83)
* chore: update package version to 1.3.0 and modify build process - Bump version from 1.2.4 to 1.3.0 in package.json - Change build script to use esbuild instead of ncc - Update devDependencies to latest versions, including @actions/core, @actions/github, eslint, and typescript - Update copyright year in main.ts to 2026 - Add return_run_details to API call and set additional outputs for runId, runUrl, and runUrlHtml - Update TypeScript configuration to target ES2022 and use ESNext module resolution * feat: add wait-for-completion input to handle workflow run completion * feat: update workflows and README for improved functionality and clarity * feat: enhance echo workflow with wait functionality and update README for clarity * feat: add wait-timeout-seconds input and enhance wait for completion logic in workflows * feat: enhance wait-for-completion logging to include timeout duration * Refactor code structure for improved readability and maintainability * fix: update timeout warning message for clarity in workflow run status
1 parent e2e5e9a commit a54f9d1

File tree

13 files changed

+24221
-31219
lines changed

13 files changed

+24221
-31219
lines changed

.github/workflows/build-test.yaml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out repository
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v6
1717

18-
- name: Build with ncc
18+
- name: Build with esbuild
1919
run: |
2020
npm install
2121
npm run build
@@ -34,19 +34,5 @@ jobs:
3434
- name: Invoke echo 1 workflow by id
3535
uses: ./
3636
with:
37-
workflow: "1854247"
37+
workflow: '1854247'
3838
inputs: '{"message": "Mango jam"}'
39-
40-
# - name: Push dist back to GitHub
41-
# uses: ad-m/github-push-action@master
42-
# with:
43-
# github_token: ${{ secrets.GITHUB_TOKEN }}
44-
# branch: ${{ github.ref }}
45-
46-
# - name: Invoke external workflow using this action
47-
# uses: ./
48-
# with:
49-
# workflow: Deploy To Kubernetes
50-
# repo: benc-uk/dapr-store
51-
# token: ${{ secrets.PERSONAL_TOKEN }}
52-
# ref: master

.github/workflows/echo-2.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
name: Message Echo 2
22

3-
on:
3+
on:
44
workflow_dispatch:
55
inputs:
66
message:
7-
description: "Message to echo"
7+
description: 'Message to echo'
88
required: false
9-
default: "this is echo 2"
9+
default: 'this is echo 2'
1010

1111
jobs:
1212
echo:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Echo message
16-
run: echo '${{ inputs.message }}'
15+
- name: Echo message slowly with a wait
16+
run: |
17+
sleep 125
18+
echo '${{ inputs.message }}'

.github/workflows/test.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
name: Workflow Tester
22

3-
on:
3+
on:
44
workflow_dispatch:
55

66
jobs:
77
testAction:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
11-
- name: Invoke echo 1
12-
uses: ./
13-
with:
14-
workflow: echo-1.yaml
15-
inputs: '{"message": "blah blah this is a test"}'
16-
- name: Invoke echo 2
17-
uses: ./
18-
with:
19-
workflow: Message Echo 2
20-
inputs: '{"message": "mushrooms in the morning"}'
10+
- uses: actions/checkout@v6
11+
- name: Invoke echo 1
12+
uses: ./
13+
with:
14+
workflow: echo-1.yaml
15+
inputs: '{"message": "blah blah this is a test"}'
16+
- name: Invoke echo 2
17+
uses: ./
18+
with:
19+
workflow: Message Echo 2
20+
inputs: '{"message": "mushrooms in the morning"}'
21+
wait-for-completion: true
22+
wait-timeout-seconds: 26

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"editor.codeActionsOnSave": {
3-
"source.fixAll.eslint": true
3+
"source.fixAll.eslint": "explicit"
44
},
55
"eslint.format.enable": true,
66
"[typescript]": {

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Copyright 2020 Ben Coleman
1+
Copyright 2026 Ben Coleman
22

33
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:
44

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

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

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The workflow must be configured for this event type e.g. `on: [workflow_dispatch
55

66
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.
77

8+
**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!
9+
10+
![Screenshot the logs of a workflow run](./etc/screen.png)
11+
812
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/)
913

1014
_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.
@@ -50,9 +54,22 @@ workflow: 1218419
5054

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

57+
### `wait-for-completion`
58+
59+
**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`.
60+
61+
### `wait-timeout-seconds`
62+
63+
**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).
64+
5365
## Action Outputs
5466

55-
This Action emits a single output named `workflowId`.
67+
| Output | Description |
68+
| ------------ | --------------------------------------------------- |
69+
| `runId` | The ID of the workflow run that was triggered |
70+
| `runUrl` | The API URL of the workflow run that was triggered |
71+
| `runUrlHtml` | The HTML URL of the workflow run that was triggered |
72+
| `workflowId` | The ID of the workflow that was triggered |
5673

5774
## Example usage
5875

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

6683
```yaml
67-
- name: Invoke workflow with inputs
84+
- name: Invoke workflow with inputs & wait
6885
uses: benc-uk/workflow-dispatch@v1
6986
with:
7087
workflow: Another Workflow
7188
inputs: '{ "message": "blah blah", "something": true }'
89+
wait-for-completion: true
7290
```
7391

7492
```yaml
@@ -79,5 +97,5 @@ This Action emits a single output named `workflowId`.
7997
repo: benc-uk/example
8098
inputs: '{ "message": "blah blah", "something": false }'
8199
# Required when using the `repo` option. Either a PAT or a token generated from the GitHub app or CLI
82-
token: "${{ secrets.MY_TOKEN }}"
100+
token: '${{ secrets.MY_TOKEN }}'
83101
```

action.yaml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
name: "Workflow Dispatch"
2-
description: "Trigger and chain GitHub Actions workflows with workflow_dispatch events"
1+
name: 'Workflow Dispatch'
2+
description: 'Trigger and chain GitHub Actions workflows with workflow_dispatch events'
33

44
inputs:
55
workflow:
6-
description: "Name, filename or ID of workflow to run"
6+
description: 'Name, filename or ID of workflow to run'
77
required: true
88
token:
9-
description: "GitHub token with repo write access, only required if the workflow is in a different repository"
9+
description: 'GitHub token with repo write access, only required if the workflow is in a different repository'
1010
required: false
1111
default: ${{ github.token }}
1212
inputs:
13-
description: "Inputs to pass to the workflow, must be a JSON string"
13+
description: 'Inputs to pass to the workflow, must be a JSON string'
1414
required: false
1515
ref:
16-
description: "The reference can be a branch, tag, or a commit SHA"
16+
description: 'The reference can be a branch, tag, or a commit SHA'
1717
required: false
1818
repo:
19-
description: "Repo owner & name, slash separated, only set if invoking a workflow in a different repo"
19+
description: 'Repo owner & name, slash separated, only set if invoking a workflow in a different repo'
2020
required: false
21+
wait-for-completion:
22+
description: 'Whether to wait for the workflow run to complete before finishing this action'
23+
required: false
24+
default: false
25+
wait-timeout-seconds:
26+
description: 'Maximum time in seconds to wait for the workflow run to complete before timing out (only applies if wait-for-completion is true)'
27+
required: false
28+
default: 900
29+
30+
outputs:
31+
runId:
32+
description: 'The ID of the workflow run that was triggered'
33+
runUrl:
34+
description: 'The API URL of the workflow run that was triggered'
35+
runUrlHtml:
36+
description: 'The HTML URL of the workflow run that was triggered'
37+
workflowId:
38+
description: 'The ID of the workflow that was triggered'
2139

2240
runs:
23-
using: "node20"
24-
main: "dist/index.js"
41+
using: 'node24'
42+
main: 'dist/index.js'
2543

2644
branding:
2745
color: purple

0 commit comments

Comments
 (0)