Skip to content

Commit

Permalink
Include the GITHUB_TOKEN/GITEA_TOKEN secret for fork pull requests (#…
Browse files Browse the repository at this point in the history
…26759) (#26806)

Backport #26759

Co-authored-by: Jason Song <i@wolfogre.com>
  • Loading branch information
js6pak and wolfogre authored Aug 30, 2023
1 parent c3d323f commit 54cc459
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions routers/api/actions/runner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ func pickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv

func getSecretsOfTask(ctx context.Context, task *actions_model.ActionTask) map[string]string {
secrets := map[string]string{}

secrets["GITHUB_TOKEN"] = task.Token
secrets["GITEA_TOKEN"] = task.Token

if task.Job.Run.IsForkPullRequest {
// ignore secrets for fork pull request
// ignore secrets for fork pull request, except GITHUB_TOKEN and GITEA_TOKEN which are automatically generated.
return secrets
}

Expand All @@ -78,13 +82,6 @@ func getSecretsOfTask(ctx context.Context, task *actions_model.ActionTask) map[s
}
}

if _, ok := secrets["GITHUB_TOKEN"]; !ok {
secrets["GITHUB_TOKEN"] = task.Token
}
if _, ok := secrets["GITEA_TOKEN"]; !ok {
secrets["GITEA_TOKEN"] = task.Token
}

return secrets
}

Expand Down

0 comments on commit 54cc459

Please sign in to comment.