diff --git a/src/Runner.Worker/GitHubContext.cs b/src/Runner.Worker/GitHubContext.cs index ac6566ad9..1ecca19f0 100644 --- a/src/Runner.Worker/GitHubContext.cs +++ b/src/Runner.Worker/GitHubContext.cs @@ -9,6 +9,7 @@ namespace GitHub.Runner.Worker private readonly HashSet _contextEnvWhitelist = new HashSet(StringComparer.OrdinalIgnoreCase) { "action", + "action_path", "actor", "api_url", "base_ref", diff --git a/src/Runner.Worker/Handlers/CompositeActionHandler.cs b/src/Runner.Worker/Handlers/CompositeActionHandler.cs index 50015a574..e83b5fb67 100644 --- a/src/Runner.Worker/Handlers/CompositeActionHandler.cs +++ b/src/Runner.Worker/Handlers/CompositeActionHandler.cs @@ -56,6 +56,14 @@ namespace GitHub.Runner.Worker.Handlers childScopeName = $"__{Guid.NewGuid()}"; } + // Copy the github context so that we don't modify the original pointer + // We can't use PipelineContextData.Clone() since that creates a null pointer exception for copying a GitHubContext + var compositeGitHubContext = new GitHubContext(); + foreach (var pair in githubContext) + { + compositeGitHubContext[pair.Key] = pair.Value; + } + foreach (Pipelines.ActionStep actionStep in actionSteps) { var actionRunner = HostContext.CreateService(); @@ -64,6 +72,11 @@ namespace GitHub.Runner.Worker.Handlers actionRunner.Condition = actionStep.Condition; var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment); + + // Set GITHUB_ACTION_PATH + step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext; + step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory); + compositeSteps.Add(step); } @@ -176,9 +189,6 @@ namespace GitHub.Runner.Worker.Handlers var actionStep = step as IActionRunner; - // Set GITHUB_ACTION - step.ExecutionContext.SetGitHubContext("action", step.ExecutionContext.GetFullyQualifiedContextName()); - try { // Evaluate and merge action's env block to env context