Skip to content

Commit

Permalink
refactor: pass github instance to newRemoteAction constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd authored and github-actions committed Mar 15, 2022
1 parent b08949f commit 5ced16b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/runner/run_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ func isLocalCheckout(ghc *model.GithubContext, step *model.Step) bool {
if step.Type() != model.StepTypeUsesActionRemote {
return false
}
remoteAction := newRemoteAction(step.Uses)
remoteAction := newRemoteAction(step.Uses, "github.com")
if remoteAction == nil {
// IsCheckout() will nil panic if we dont bail out early
return false
Expand Down
8 changes: 3 additions & 5 deletions pkg/runner/step_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ func (sc *StepContext) Executor(ctx context.Context) common.Executor {
sc.runAction(actionDir, "", "", "", true),
)
case model.StepTypeUsesActionRemote:
remoteAction := newRemoteAction(step.Uses)
remoteAction := newRemoteAction(step.Uses, rc.Config.GitHubInstance)
if remoteAction == nil {
return common.NewErrorExecutor(formatError(step.Uses))
}

remoteAction.URL = rc.Config.GitHubInstance

github := rc.getGithubContext()
if remoteAction.IsCheckout() && isLocalCheckout(github, step) {
return func(ctx context.Context) error {
Expand Down Expand Up @@ -713,7 +711,7 @@ func (ra *remoteAction) IsCheckout() bool {
return false
}

func newRemoteAction(action string) *remoteAction {
func newRemoteAction(action, githubInstance string) *remoteAction {
// GitHub's document[^] describes:
// > We strongly recommend that you include the version of
// > the action you are using by specifying a Git ref, SHA, or Docker tag number.
Expand All @@ -729,7 +727,7 @@ func newRemoteAction(action string) *remoteAction {
Repo: matches[2],
Path: matches[4],
Ref: matches[6],
URL: "github.com",
URL: githubInstance,
}
}

Expand Down

0 comments on commit 5ced16b

Please sign in to comment.