Rework inputs handling of update workflow for trigger 'workflow_call'#2154
Rework inputs handling of update workflow for trigger 'workflow_call'#2154OleWunschmann wants to merge 2 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes how the “Update AL-Go System Files” reusable workflow reads inputs when invoked via workflow_call, and adds an override mechanism in GetWorkflowMultiRunBranches so branch selection behaves the same for workflow_call as for workflow_dispatch.
Changes:
- Add
workflowEventNameinput toGetWorkflowMultiRunBranchesand treatworkflow_calllikeworkflow_dispatch. - Rework UpdateGitHubGoSystemFiles reusable workflow templates to use
inputs.*and introduce a required__callermarker input to detect workflow_call usage. - Extend Pester coverage for
workflow_calland parameter override behavior; update release notes.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Actions/GetWorkflowMultiRunBranches/GetWorkflowMultiRunBranches.ps1 | Switches event handling to use a parameter override and adds workflow_call handling. |
| Actions/GetWorkflowMultiRunBranches/action.yaml | Exposes new workflowEventName input and passes it through to the script. |
| Actions/GetWorkflowMultiRunBranches/README.md | Documents the new input. |
| Templates/AppSource App/.github/workflows/UpdateGitHubGoSystemFiles.yaml | Updates reusable workflow input handling and passes overridden event name into branch selection. |
| Templates/Per Tenant Extension/.github/workflows/UpdateGitHubGoSystemFiles.yaml | Same workflow_call input handling changes as the AppSource template. |
| Tests/GetWorkflowMultiRunBranches.Test.ps1 | Adds workflow_call scenarios and verifies workflowEventName override behavior. |
| RELEASENOTES.md | Notes the workflow_call input-handling rework. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Write-Host "Event is workflow_dispatch: getting branches from input" | ||
| { $_ -in 'workflow_dispatch', 'workflow_call' } { | ||
| Write-Host "Event is $($_): getting branches from input" | ||
| $branchPatterns = @($includeBranches.Split(',') | ForEach-Object { $_.Trim() }) |
There was a problem hiding this comment.
In the workflow_dispatch/workflow_call branch, $includeBranches.Split(',') will throw when -includeBranches isn’t provided (null) and will produce a single empty pattern when the action passes the default empty string. In both cases the later if (-not $branchPatterns) { ... } fallback won’t reliably select the current branch, so the action can fail or return an empty branch list even though the docs/tests expect it to default to GITHUB_REF_NAME. Treat null/whitespace includeBranches as “no patterns” (and/or filter out empty patterns after split) before populating $branchPatterns.
| $branchPatterns = @($includeBranches.Split(',') | ForEach-Object { $_.Trim() }) | |
| if (-not [string]::IsNullOrWhiteSpace($includeBranches)) { | |
| $branchPatterns = @( | |
| $includeBranches.Split(',') | | |
| ForEach-Object { $_.Trim() } | | |
| Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | |
| ) | |
| } | |
| else { | |
| $branchPatterns = @() | |
| } |
❔What, Why & How
What
The
workflow_callinputs in the update workflow are handled incorrectly.They must be accessed as
inputs.*, notgithub.event.inputs.*.Also,
github.event_namewill 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
directCommititself 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
GetWorkflowMultiRunBranches:workflowEventNamegithub.event_nameworkflow_callresuls in the same output as eventworkflow_dispatchgithub.event.inputs.*withinputs.*__caller(string):WorkflowEventName:github.ref_nameor toworkflow_callwhen the__callerinput is presentworkflowEventNameof actionGetWorkflowMultiRunBranchesRelated to original discussion #1855 and PR #2031
✅ Checklist