diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index e4ca1b2..b9ece35 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -874,6 +874,18 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext ghc.APIURL = fmt.Sprintf("https://%s/api/v3", rc.Config.GitHubInstance) ghc.GraphQLURL = fmt.Sprintf("https://%s/api/graphql", rc.Config.GitHubInstance) } + + { // Adapt to Gitea + instance := rc.Config.GitHubInstance + if !strings.HasPrefix(instance, "http://") && + !strings.HasPrefix(instance, "https://") { + instance = "https://" + instance + } + ghc.ServerURL = instance + ghc.APIURL = instance + "/api/v1" // the version of Gitea is v1 + ghc.GraphQLURL = "" // Gitea doesn't support graphql + } + // allow to be overridden by user if rc.Config.Env["GITHUB_SERVER_URL"] != "" { ghc.ServerURL = rc.Config.Env["GITHUB_SERVER_URL"] diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go index 78e97ed..0b5c5be 100644 --- a/pkg/runner/step_action_remote.go +++ b/pkg/runner/step_action_remote.go @@ -49,8 +49,6 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor { } github := sar.getGithubContext(ctx) - sar.remoteAction.URL = github.ServerURL - if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout { common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied") return nil @@ -225,11 +223,7 @@ type remoteAction struct { Ref string } -func (ra *remoteAction) CloneURL(defaultURL string) string { - u := ra.URL - if u == "" { - u = defaultURL - } +func (ra *remoteAction) CloneURL(u string) string { if !strings.HasPrefix(u, "http://") && !strings.HasPrefix(u, "https://") { u = "https://" + u } @@ -244,6 +238,9 @@ func (ra *remoteAction) IsCheckout() bool { } func (ra *remoteAction) GetAvailableCloneURL(actionURLs []string) (string, error) { + if ra.URL != "" { + return ra.CloneURL(ra.URL), nil + } for _, u := range actionURLs { cloneURL := ra.CloneURL(u) resp, err := detectActionClient.Get(cloneURL)