Skip to content

Commit 515c2c4

Browse files
tomaszduda23wolfogre
authored andcommitted
fix action cloning, set correct server_url for act_runner exec (#68)
1. Newest act is not able to clone action based on --default-actions-url It might be side effect of https://gitea.com/gitea/act/pulls/67. 2. Set correct server_url, api_url, graphql_url for act_runner exec Reviewed-on: https://gitea.com/gitea/act/pulls/68 Reviewed-by: Jason Song <[email protected]> Co-authored-by: Tomasz Duda <[email protected]> Co-committed-by: Tomasz Duda <[email protected]>
1 parent a165e17 commit 515c2c4

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

pkg/runner/run_context.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,18 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
874874
ghc.APIURL = fmt.Sprintf("https://%s/api/v3", rc.Config.GitHubInstance)
875875
ghc.GraphQLURL = fmt.Sprintf("https://%s/api/graphql", rc.Config.GitHubInstance)
876876
}
877+
878+
{ // Adapt to Gitea
879+
instance := rc.Config.GitHubInstance
880+
if !strings.HasPrefix(instance, "http://") &&
881+
!strings.HasPrefix(instance, "https://") {
882+
instance = "https://" + instance
883+
}
884+
ghc.ServerURL = instance
885+
ghc.APIURL = instance + "/api/v1" // the version of Gitea is v1
886+
ghc.GraphQLURL = "" // Gitea doesn't support graphql
887+
}
888+
877889
// allow to be overridden by user
878890
if rc.Config.Env["GITHUB_SERVER_URL"] != "" {
879891
ghc.ServerURL = rc.Config.Env["GITHUB_SERVER_URL"]

pkg/runner/step_action_remote.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
4949
}
5050

5151
github := sar.getGithubContext(ctx)
52-
sar.remoteAction.URL = github.ServerURL
53-
5452
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
5553
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
5654
return nil
@@ -225,11 +223,7 @@ type remoteAction struct {
225223
Ref string
226224
}
227225

228-
func (ra *remoteAction) CloneURL(defaultURL string) string {
229-
u := ra.URL
230-
if u == "" {
231-
u = defaultURL
232-
}
226+
func (ra *remoteAction) CloneURL(u string) string {
233227
if !strings.HasPrefix(u, "http://") && !strings.HasPrefix(u, "https://") {
234228
u = "https://" + u
235229
}
@@ -244,6 +238,9 @@ func (ra *remoteAction) IsCheckout() bool {
244238
}
245239

246240
func (ra *remoteAction) GetAvailableCloneURL(actionURLs []string) (string, error) {
241+
if ra.URL != "" {
242+
return ra.CloneURL(ra.URL), nil
243+
}
247244
for _, u := range actionURLs {
248245
cloneURL := ra.CloneURL(u)
249246
resp, err := detectActionClient.Get(cloneURL)

0 commit comments

Comments
 (0)