Skip to content

Commit

Permalink
Use artifacts v4 jwt if available (#471)
Browse files Browse the repository at this point in the history
Needs go-gitea/gitea#28885 to provide jwt if sent by server

Could fix #459, but that has not been verified.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/471
Reviewed-by: delvh <dev.lh@web.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
  • Loading branch information
ChristopherHX and lunny committed Feb 8, 2024
1 parent f1f9142 commit e6630e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/app/run/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ 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
giteaRuntimeToken := taskContext["gitea_runtime_token"].GetStringValue()
if giteaRuntimeToken == "" {
// use task token to action api token for previous Gitea Server Versions
giteaRuntimeToken = preset.Token
}
r.envs["ACTIONS_RUNTIME_TOKEN"] = giteaRuntimeToken

eventJSON, err := json.Marshal(preset.Event)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/pkg/report/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func NewReporter(ctx context.Context, cancel context.CancelFunc, client client.C
if v := task.Context.Fields["token"].GetStringValue(); v != "" {
oldnew = append(oldnew, v, "***")
}
if v := task.Context.Fields["gitea_runtime_token"].GetStringValue(); v != "" {
oldnew = append(oldnew, v, "***")
}
for _, v := range task.Secrets {
oldnew = append(oldnew, v, "***")
}
Expand Down

0 comments on commit e6630e2

Please sign in to comment.