Skip to content

Rework inputs handling of update workflow for trigger 'workflow_call'#2154

Open
OleWunschmann wants to merge 2 commits intomicrosoft:mainfrom
OleWunschmann:fix-reusable-update-workflow
Open

Rework inputs handling of update workflow for trigger 'workflow_call'#2154
OleWunschmann wants to merge 2 commits intomicrosoft:mainfrom
OleWunschmann:fix-reusable-update-workflow

Conversation

@OleWunschmann
Copy link
Contributor

@OleWunschmann OleWunschmann commented Mar 4, 2026

❔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

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md

@OleWunschmann OleWunschmann marked this pull request as ready for review March 4, 2026 21:55
@OleWunschmann OleWunschmann requested a review from a team as a code owner March 4, 2026 21:55
Copilot AI review requested due to automatic review settings March 4, 2026 21:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 workflowEventName input to GetWorkflowMultiRunBranches and treat workflow_call like workflow_dispatch.
  • Rework UpdateGitHubGoSystemFiles reusable workflow templates to use inputs.* and introduce a required __caller marker input to detect workflow_call usage.
  • Extend Pester coverage for workflow_call and 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() })
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
$branchPatterns = @($includeBranches.Split(',') | ForEach-Object { $_.Trim() })
if (-not [string]::IsNullOrWhiteSpace($includeBranches)) {
$branchPatterns = @(
$includeBranches.Split(',') |
ForEach-Object { $_.Trim() } |
Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
)
}
else {
$branchPatterns = @()
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants