Skip to content

Commit

Permalink
Add an environment variable to indicate which repository the currentl…
Browse files Browse the repository at this point in the history
…y 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 <[email protected]>
  • Loading branch information
chrisgavin and TingluoHuang authored Nov 3, 2020
1 parent 3ebaeb9 commit 95e2158
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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",
"action_repository",
"actor",
"api_url",
"base_ref",
Expand Down Expand Up @@ -55,4 +57,4 @@ public GitHubContext ShallowCopy()
return copy;
}
}
}
}

0 comments on commit 95e2158

Please sign in to comment.