You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rework inputs handling of update workflow for trigger 'workflow_call' (#2154)
### ❔What, Why & How
#### What
The `workflow_call` inputs in the update workflow are handled
incorrectly.
They must be accessed as `inputs.*`, not `github.event.inputs.*`.
Also, `github.event_name` will always reflect the trigger of the
*calling* workflow, not the reusable workflow itself.
In my tests of the original contribution that added the trigger to the
update workflow, my use case tests passed by coincidence because the
parent workflow had an input named `directCommit` itself and all other
inputs used their default values.
#### Why
When the update workflow is invoked as a reusable workflow, it should
use the values defined in its own inputs.
These should be treated the same as when the workflow is triggered by
`workflow_dispatch` (for example, when determining branches).
#### How
- Modified the action `GetWorkflowMultiRunBranches`:
- Added a new optional input `workflowEventName`
- Default: `github.event_name`
- Purpose: override the event name used to determine which branches to
include
- Event `workflow_call` resuls in the same output as event
`workflow_dispatch`
- Modified the update workflow:
- Replaced all uses of `github.event.inputs.*` with `inputs.*`
- Added a new required workflow_call input `caller` (string):
- Marks that the update workflow was called from another workflow
- Added a new environment variable `WorkflowEventName`:
- Set to `github.ref_name` or to `workflow_call` when the `caller` input
is present
- Passed to input `workflowEventName` of action
`GetWorkflowMultiRunBranches`
- Used to determine the commit options
Related to original discussion #1855 and PR #2031
### ✅ Checklist
- [x] Add tests (E2E, unit tests)
- [x] Update RELEASENOTES.md
[Parameter(Mandatory=$false,HelpMessage="Comma-separated value of branch name patterns to include if they exist. If not specified, only the current branch is returned. Wildcards are supported.")]
Copy file name to clipboardExpand all lines: Actions/GetWorkflowMultiRunBranches/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ If the workflow is run on a schedule, the branches are determined based on the `
17
17
| Name | Required | Description | Default value |
18
18
| :-- | :-: | :-- | :-- |
19
19
| shell | false | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
20
+
| workflowEventName | false | The GitHub event name that triggered the workflow. *(override for reusable workflows)*| github.event_name |
20
21
| includeBranches | false | Comma-separated value of branch name patterns to include if they exist. If not specified, only the current branch is returned. Wildcards are supported. |''|
Copy file name to clipboardExpand all lines: Actions/GetWorkflowMultiRunBranches/action.yaml
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,10 @@ inputs:
5
5
description: Shell in which you want to run the action (powershell or pwsh)
6
6
required: false
7
7
default: powershell
8
+
workflowEventName:
9
+
description: The GitHub event name that triggered the workflow.
10
+
required: false
11
+
default: ${{ github.event_name }}
8
12
includeBranches:
9
13
description: Comma-separated value of branch name patterns to include if they exist. If not specified, only the current branch is returned. Wildcards are supported.
0 commit comments