Add pull request labels as environment variable (#1321)

Closes #1308 

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
Lukas
2023-03-17 03:43:04 +01:00
committed by GitHub
parent 7e3bf2202c
commit 1b43b0bf20
9 changed files with 64 additions and 22 deletions

View File

@@ -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
}

View File

@@ -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())