diff options
author | Zettat123 <zettat123@gmail.com> | 2023-06-06 06:03:02 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2023-06-06 06:03:02 +0200 |
commit | fed01c980790cf7bbec0e4330546233557b15af8 (patch) | |
tree | 36c7c311d4a7b024ad32b6145684d34f261c8e17 /internal | |
parent | docs: improve examples README and organization (#230) (diff) | |
download | forgejo-runner-fed01c980790cf7bbec0e4330546233557b15af8.tar.xz forgejo-runner-fed01c980790cf7bbec0e4330546233557b15af8.zip |
Parse multiple default actions URLs (#200)
Follow https://gitea.com/gitea/act/pulls/58
Resolve https://github.com/go-gitea/gitea/issues/24789
Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/200
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r-- | internal/app/run/runner.go | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index a36adad..d636608 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -177,26 +177,26 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. Workdir: filepath.FromSlash(fmt.Sprintf("/%s/%s", r.cfg.Container.WorkdirParent, preset.Repository)), BindWorkdir: false, - ReuseContainers: false, - ForcePull: false, - ForceRebuild: false, - LogOutput: true, - JSONLogger: false, - Env: r.envs, - Secrets: task.Secrets, - GitHubInstance: strings.TrimSuffix(r.client.Address(), "/"), - AutoRemove: true, - NoSkipCheckout: true, - PresetGitHubContext: preset, - EventJSON: string(eventJSON), - ContainerNamePrefix: fmt.Sprintf("GITEA-ACTIONS-TASK-%d", task.Id), - ContainerMaxLifetime: maxLifetime, - ContainerNetworkMode: container.NetworkMode(r.cfg.Container.Network), - ContainerOptions: r.cfg.Container.Options, - Privileged: r.cfg.Container.Privileged, - DefaultActionInstance: taskContext["gitea_default_actions_url"].GetStringValue(), - PlatformPicker: r.labels.PickPlatform, - Vars: task.Vars, + ReuseContainers: false, + ForcePull: false, + ForceRebuild: false, + LogOutput: true, + JSONLogger: false, + Env: r.envs, + Secrets: task.Secrets, + GitHubInstance: strings.TrimSuffix(r.client.Address(), "/"), + AutoRemove: true, + NoSkipCheckout: true, + PresetGitHubContext: preset, + EventJSON: string(eventJSON), + ContainerNamePrefix: fmt.Sprintf("GITEA-ACTIONS-TASK-%d", task.Id), + ContainerMaxLifetime: maxLifetime, + ContainerNetworkMode: container.NetworkMode(r.cfg.Container.Network), + ContainerOptions: r.cfg.Container.Options, + Privileged: r.cfg.Container.Privileged, + DefaultActionsURLs: parseDefaultActionsURLs(taskContext["gitea_default_actions_url"].GetStringValue()), + PlatformPicker: r.labels.PickPlatform, + Vars: task.Vars, } rr, err := runner.New(runnerConfig) @@ -214,3 +214,13 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. reporter.SetOutputs(job.Outputs) return execErr } + +func parseDefaultActionsURLs(s string) []string { + urls := strings.Split(s, ",") + trimmed := make([]string, 0, len(urls)) + for _, u := range urls { + t := strings.TrimRight(strings.TrimSpace(u), "/") + trimmed = append(trimmed, t) + } + return trimmed +} |