diff options
author | Zettat123 <zettat123@gmail.com> | 2024-03-05 09:07:29 +0100 |
---|---|---|
committer | Jason Song <i@wolfogre.com> | 2024-03-05 09:07:29 +0100 |
commit | 0cc67b88172215916d3bd8f8e7e83fab30c2b08b (patch) | |
tree | 44b6bd4130beb0d2672d3bf4847311122a320174 /pkg/runner | |
parent | Patched options() to let container options propagate to job containers (#80) (diff) | |
download | forgejo-act-0cc67b88172215916d3bd8f8e7e83fab30c2b08b.tar.xz forgejo-act-0cc67b88172215916d3bd8f8e7e83fab30c2b08b.zip |
Support cloning remote actions from insecure Gitea instances (#92)
Related to https://github.com/go-gitea/gitea/issues/28693
Reviewed-on: https://gitea.com/gitea/act/pulls/92
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
Diffstat (limited to 'pkg/runner')
-rw-r--r-- | pkg/runner/runner.go | 1 | ||||
-rw-r--r-- | pkg/runner/step_action_remote.go | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 015c364..b08e715 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -72,6 +72,7 @@ type Config struct { PlatformPicker func(labels []string) string // platform picker, it will take precedence over Platforms if isn't nil JobLoggerLevel *log.Level // the level of job logger ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers + InsecureSkipTLS bool // whether to skip verifying TLS certificate of the Gitea instance } // GetToken: Adapt to Gitea diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go index 3243188..ed4d94e 100644 --- a/pkg/runner/step_action_remote.go +++ b/pkg/runner/step_action_remote.go @@ -121,6 +121,8 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor { But for Gitea, tasks triggered by a.com can clone actions from b.com. */ OfflineMode: sar.RunContext.Config.ActionOfflineMode, + + InsecureSkipTLS: sar.cloneSkipTLS(), // For Gitea }) var ntErr common.Executor if err := gitClone(ctx); err != nil { @@ -258,6 +260,22 @@ func (sar *stepActionRemote) getCompositeSteps() *compositeSteps { return sar.compositeSteps } +// For Gitea +// cloneSkipTLS returns true if the runner can clone an action from the Gitea instance +func (sar *stepActionRemote) cloneSkipTLS() bool { + if !sar.RunContext.Config.InsecureSkipTLS { + // Return false if the Gitea instance is not an insecure instance + return false + } + if sar.remoteAction.URL == "" { + // Empty URL means the default action instance should be used + // Return true if the URL of the Gitea instance is the same as the URL of the default action instance + return sar.RunContext.Config.DefaultActionInstance == sar.RunContext.Config.GitHubInstance + } + // Return true if the URL of the remote action is the same as the URL of the Gitea instance + return sar.remoteAction.URL == sar.RunContext.Config.GitHubInstance +} + type remoteAction struct { URL string Org string |