1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-28 03:28:13 +00:00

feat: generate token for task

This commit is contained in:
Jason Song
2022-10-31 14:45:39 +08:00
parent 30df383ca0
commit b4b22e78ad
2 changed files with 37 additions and 6 deletions

View File

@@ -294,16 +294,23 @@ func pickTask(ctx context.Context, runner *bots_model.Runner) (*runnerv1.Task, b
"ref_type": "",
"head_ref": "",
"base_ref": "",
"token": "",
"token": t.Token,
"repository_owner": fmt.Sprint(t.Job.Run.Repo.OwnerName),
"retention_days": "",
})
secrets := getSecretsOfTask(ctx, t)
if _, ok := secrets["GITHUB_TOKEN"]; !ok {
secrets["GITHUB_TOKEN"] = t.Token
}
if _, ok := secrets["GITEA_TOKEN"]; !ok {
secrets["GITEA_TOKEN"] = t.Token
}
task := &runnerv1.Task{
Id: t.ID,
WorkflowPayload: t.Job.WorkflowPayload,
Context: taskContext,
Secrets: getSecretsOfTask(ctx, t),
Secrets: secrets,
}
return task, true, nil
}