mirror of
https://github.com/actions/runner.git
synced 2025-12-11 21:06:55 +00:00
Support Conditional Steps in Composite Actions (#1438)
* conditional support for composite actions * Fix Conditional function evaluation * Push launch.json temporarily * Revert "Push launch.json temporarily" * rename context * Cleanup comments * fix success/failure functions to run based on pre/main steps * idea of step_status * change to use steps context, WIP * add inputs to possible if condition expressions * use action_status * pr cleanup * Added right stages * Test on stage in conditional functions * Fix naming and formatting * Fix tests * Add success and failure L0s * Remove comment * Remove whitespace * Undo formatting * Add L0 for step-if parsing * Add ADR Co-authored-by: Thomas Boop <thboop@github.com>
This commit is contained in:
@@ -24,8 +24,19 @@ namespace GitHub.Runner.Worker.Expressions
|
||||
ArgUtil.NotNull(templateContext, nameof(templateContext));
|
||||
var executionContext = templateContext.State[nameof(IExecutionContext)] as IExecutionContext;
|
||||
ArgUtil.NotNull(executionContext, nameof(executionContext));
|
||||
ActionResult jobStatus = executionContext.JobContext.Status ?? ActionResult.Success;
|
||||
return jobStatus == ActionResult.Success;
|
||||
|
||||
// Decide based on 'action_status' for composite MAIN steps and 'job.status' for pre, post and job-level steps
|
||||
var isCompositeMainStep = executionContext.IsEmbedded && executionContext.Stage == ActionRunStage.Main;
|
||||
if (isCompositeMainStep)
|
||||
{
|
||||
ActionResult actionStatus = EnumUtil.TryParse<ActionResult>(executionContext.GetGitHubContext("action_status")) ?? ActionResult.Success;
|
||||
return actionStatus == ActionResult.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionResult jobStatus = executionContext.JobContext.Status ?? ActionResult.Success;
|
||||
return jobStatus == ActionResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user