Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add an environment variable to indicate which repository the currently running Action came from. #585

Merged
merged 6 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Runner.Worker/ActionRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ Action.Reference is Pipelines.RepositoryPathReference repoAction &&
ExecutionContext.SetGitHubContext("event_path", workflowFile);
}

// Set GITHUB_ACTION_REPOSITORY if this Action is from a repository
if (Action.Reference is Pipelines.RepositoryPathReference repoPathReferenceAction &&
!string.Equals(repoPathReferenceAction.RepositoryType, Pipelines.PipelineConstants.SelfAlias, StringComparison.OrdinalIgnoreCase))
{
ExecutionContext.SetGitHubContext("action_repository", repoPathReferenceAction.Name);
ExecutionContext.SetGitHubContext("action_ref", repoPathReferenceAction.Ref);
}

// Setup container stephost for running inside the container.
if (ExecutionContext.Global.Container != null)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Runner.Worker/GitHubContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public sealed class GitHubContext : DictionaryContextData, IEnvironmentContextDa
{
"action",
"action_path",
"action_ref",
Copy link
Member

Choose a reason for hiding this comment

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

@chrispat any objection to adding these 2 new environment variables?

"action_repository",
"actor",
"api_url",
"base_ref",
Expand Down Expand Up @@ -55,4 +57,4 @@ public GitHubContext ShallowCopy()
return copy;
}
}
}
}