-
Notifications
You must be signed in to change notification settings - Fork 311
Add per-handler staged mode to all safe output types #22284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ const HANDLER_TYPE = "dispatch_workflow"; | |
| const { getErrorMessage } = require("./error_helpers.cjs"); | ||
| const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs"); | ||
| const { resolveTargetRepoConfig, parseRepoSlug, validateTargetRepo } = require("./repo_helpers.cjs"); | ||
| const { logStagedPreviewInfo } = require("./staged_preview.cjs"); | ||
| const { isStagedMode } = require("./safe_output_helpers.cjs"); | ||
|
|
||
| /** | ||
| * Main handler factory for dispatch_workflow | ||
|
|
@@ -73,6 +75,7 @@ async function main(config = {}) { | |
| // Track how many items we've processed for max limit | ||
| let processedCount = 0; | ||
| let lastDispatchTime = 0; | ||
| const isStaged = isStagedMode(config); | ||
|
|
||
| // Helper function to get the default branch of the dispatch target repository | ||
| const getDefaultBranchRef = async () => { | ||
|
|
@@ -197,6 +200,17 @@ async function main(config = {}) { | |
| const workflowFile = `${workflowName}${extension}`; | ||
| core.info(`Dispatching workflow: ${workflowFile}`); | ||
|
|
||
| // If in staged mode, preview the dispatch without executing it | ||
| if (isStaged) { | ||
| logStagedPreviewInfo(`Would dispatch workflow: ${workflowFile} in ${resolvedRepoSlug} with ref: ${ref}`); | ||
| return { | ||
| success: true, | ||
| staged: true, | ||
| workflow_name: workflowName, | ||
| inputs: inputs, | ||
| }; | ||
| } | ||
|
Comment on lines
200
to
+212
|
||
|
|
||
| // Dispatch the workflow using the resolved file. | ||
| // Request return_run_details for newer GitHub API support; fall back without it | ||
| // for older GitHub Enterprise Server deployments that don't support the parameter. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The staged-mode branch is new, but the existing test suite for this handler doesn’t include assertions for staged mode. Adding a test that sets
config.staged = true(and/orGH_AW_SAFE_OUTPUTS_STAGED=true) and verifies no SARIF file is written while returning{ staged: true }would help lock in the intended behavior.