Auto label PRs (#1518)

chore: Automatically add labels to PRs, based on description

Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Sachin Sahu <75629410+SachinSahu431@users.noreply.github.com>

---------

Signed-off-by: Sachin Sahu <75629410+SachinSahu431@users.noreply.github.com>
Signed-off-by: Sachin Sahu <sachinksahu.431@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
This commit is contained in:
Sachin Sahu 2024-05-30 19:20:06 +05:30 committed by GitHub
parent 2f36f98197
commit 105a3b72ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 91 additions and 2 deletions

34
.github/labeler.yml vendored Normal file
View File

@ -0,0 +1,34 @@
# Config file for pr-auto-label workflow
# enable auto-labeler on issues, prs, or both.
enable:
prs: true
# Labels is an object where:
# - keys are labels
# - values are objects of { include: [ pattern ], exclude: [ pattern ] }
# - pattern must be a valid regex, and is applied globally to
# title + description of issues and/or prs (see enabled config above)
# - 'include' patterns will associate a label if any of these patterns match
# - 'exclude' patterns will ignore this label if any of these patterns match
labels:
'kind/BUGFIX':
include:
- '/kind (fix|bugfix)'
exclude: []
'kind/ENHANCEMENT':
include:
- '/kind enhancement'
exclude: []
'kind/FEATURE':
include:
- '/kind (feat|feature)'
exclude: []
'kind/CHANGE':
include:
- '/kind change'
exclude: []
'release-note-none':
include:
- '/kind (none|NONE|release-note-none|release-notes-none)'
exclude: []

55
.github/workflows/pr-auto-label.yml vendored Normal file
View File

@ -0,0 +1,55 @@
---
name: PR-auto-labeler
on:
pull_request_target:
types: [opened, edited, synchronize]
permissions:
contents: read # the config file
pull-requests: write # for labeling pull requests (on: pull_request_target or on: pull_request)
statuses: write # to generate status
checks: write # to generate status
jobs:
pr-labeler:
runs-on: ubuntu-latest
steps:
- name: Check Labels
id: labeler
uses: jimschubert/labeler-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Adjust the configuration in /.github/labeler.yml
validate-pr-label:
runs-on: ubuntu-latest
needs: pr-labeler
steps:
- name: Verify Label
id: preview_label_check
uses: docker://agilepathway/pull-request-label-checker:latest
with:
any_of: kind/BUGFIX,kind/ENHANCEMENT,kind/FEATURE,kind/CHANGE,release-note-none
repo_token: ${{ secrets.GITHUB_TOKEN }}
allow_failure: true
- name: Comment on Label Check Failure
uses: thollander/actions-comment-pull-request@v2.5.0
if: steps.preview_label_check.outputs.label_check == 'failure'
with:
message: |
PR body does not contain a valid type of change. Please refer to [CONTRIBUTING.md](https://github.com/prometheus/client_golang/blob/main/CONTRIBUTING.md#how-to-fill-the-pr-template) for more information.
comment_tag: labelfailure
mode: recreate
- name: Remove Label Check Failure Comment
uses: thollander/actions-comment-pull-request@v2.5.0
if: steps.preview_label_check.outputs.label_check == 'success'
with:
message: |
PR body contains a valid type of change.
comment_tag: labelfailure
mode: delete
create_if_not_exists: false
- name: Exit on Failure
if: steps.preview_label_check.outputs.label_check == 'failure'
run: exit 1

View File

@ -21,7 +21,7 @@ Prometheus uses GitHub to manage reviews of pull requests.
* Be sure to sign off on the [DCO](https://github.com/probot/dco#how-it-works)
## How to fill the PR template
## How to write a PR description
### Describe your PR