From b79c3aa1a325ab49902fd662174a5ea0f8eed196 Mon Sep 17 00:00:00 2001 From: fuxiaohei Date: Mon, 10 Apr 2023 21:35:07 +0800 Subject: [PATCH] feat: add artifact api from gitea server (#103) add action api for artifacts upload and download. It's related to https://github.com/go-gitea/gitea/pull/22738 Co-authored-by: Jason Song Reviewed-on: https://gitea.com/gitea/act_runner/pulls/103 Reviewed-by: Jason Song Co-authored-by: fuxiaohei Co-committed-by: fuxiaohei --- internal/app/run/runner.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 6e31373..1d9c91a 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "path/filepath" + "strings" "sync" "time" @@ -60,6 +61,10 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client) } } + // set artifact gitea api + artifactGiteaAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/" + envs["ACTIONS_RUNTIME_URL"] = artifactGiteaAPI + return &Runner{ name: reg.Name, cfg: cfg, @@ -149,6 +154,9 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. preset.Token = t } + // use task token to action api token + r.envs["ACTIONS_RUNTIME_TOKEN"] = preset.Token + eventJSON, err := json.Marshal(preset.Event) if err != nil { return err