Skip to content

Commit

Permalink
feat(tekton): support matching pruns via labels
Browse files Browse the repository at this point in the history
Implement annotation-based PipelineRun to label matching functionality:

- Add `pipelinesascode.tekton.dev/on-label` annotation for label-based
  PipelineRun triggers
- Support label matching on GitHub, Gitea, and GitLab providers
- Implement immediate PipelineRun triggering when labels are added
- Enable re-triggering of PipelineRuns on commit updates with existing labels
- Provide access to Pull Request labels via `{{ pull_request_labels }}`
  dynamic variable

Supported providers:
- GitHub
- Gitea
- GitLab

Limitations:
- Not supported on Bitbucket Cloud and Bitbucket Server

https://issues.redhat.com/browse/SRVKP-5950

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel committed Dec 20, 2024
1 parent d701ed2 commit e0d0ad7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/content/docs/guide/matchingevents.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ PipelineRun.
## Matching PipelineRun to a Pull Request labels

{{< tech_preview "Matching PipelineRun to a Pull-Request label" >}}
{{< support_matrix github_app="true" github_webhook="true" gitea="true" gitlab="true" bitbucket_cloud="false" bitbucket_server="false" >}}

Using the annotation `pipelinesascode.tekton.dev/on-label`, you can match a
PipelineRun to a Pull Request label. For example, if you want to match the
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/github/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ func (v *Provider) createStatusCommit(ctx context.Context, runevent *info.Event,
if opscomments.IsAnyOpsEventType(eventType.String()) {
eventType = triggertype.PullRequest
}
if (status.Status == "completed" ||
(status.Status == "queued" && status.Title == pendingApproval)) &&

if (status.Status == "completed" || (status.Status == "queued" && status.Title == pendingApproval)) &&
status.Text != "" && eventType == triggertype.PullRequest {
_, _, err = v.Client.Issues.CreateComment(ctx, runevent.Organization, runevent.Repository,
runevent.PullRequestNumber,
Expand Down

0 comments on commit e0d0ad7

Please sign in to comment.