Skip to content

Commit

Permalink
Created github action to check that a label has been added before mer…
Browse files Browse the repository at this point in the history
…ge (#2605)

* Created github action to check that a label has been added before merging

* added case for ignore for release
  • Loading branch information
adamhaeger authored Oct 21, 2024
1 parent 5780874 commit a44c191
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/check-label-added.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Label Check"
on:
pull_request:
types: [opened, edited, labeled, unlabeled, synchronize]

jobs:
check-label:
runs-on: ubuntu-latest
steps:
- name: Check labels
uses: actions/github-script@v6
with:
script: |
const labels = context.payload.pull_request.labels;
const hasIgnoreLabel = labels.some(label => label.name === 'ignore-for-release');
if (!hasIgnoreLabel) {
const hasMatchingLabel = labels.some(label => /^kind\/.*/.test(label.name));
if (!hasMatchingLabel) {
core.setFailed('The PR must have at least one label matching the pattern "kind/*", unless it has the "ignore-for-release" label.');
}
}

0 comments on commit a44c191

Please sign in to comment.