mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
Add pull request labels as environment variable (#1321)
Closes #1308 Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
@@ -164,3 +164,13 @@ func convertRepoHook(eventRepo *github.PushEventRepository) *model.Repo {
|
||||
}
|
||||
return repo
|
||||
}
|
||||
|
||||
// covertLabels is a helper function used to convert a GitHub label list to
|
||||
// the common Woodpecker label structure.
|
||||
func convertLabels(from []*github.Label) []string {
|
||||
labels := make([]string, len(from))
|
||||
for i, label := range from {
|
||||
labels[i] = *label.Name
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullReque
|
||||
hook.GetPullRequest().GetHead().GetRef(),
|
||||
hook.GetPullRequest().GetBase().GetRef(),
|
||||
),
|
||||
PullRequestLabels: convertLabels(hook.GetPullRequest().Labels),
|
||||
}
|
||||
if merge {
|
||||
pipeline.Ref = fmt.Sprintf(mergeRefs, hook.GetPullRequest().GetNumber())
|
||||
|
||||
Reference in New Issue
Block a user