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

* add `workflow_dispatch`

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

* Expose the Action ref as well.

* Move setting `github.action_repository` and `github.action_ref` to `ActionRunner.cs`.

* Don't set `action_repository` and `action_ref` for local Actions.

Co-authored-by: Tingluo Huang <tingluohuang@github.com>
This commit is contained in:
Chris Gavin
2020-11-03 19:39:17 +00:00
committed by GitHub
parent 3ebaeb9f19
commit 95e2158dc6
2 changed files with 11 additions and 1 deletions

View File

@@ -135,6 +135,14 @@ namespace GitHub.Runner.Worker
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)
{

View File

@@ -10,6 +10,8 @@ namespace GitHub.Runner.Worker
{
"action",
"action_path",
"action_ref",
"action_repository",
"actor",
"api_url",
"base_ref",
@@ -55,4 +57,4 @@ namespace GitHub.Runner.Worker
return copy;
}
}
}
}