Skip to content

Commit

Permalink
Merge pull request #10 from reshamas/2-rs-ghactions-labels
Browse files Browse the repository at this point in the history
Add GH action to require a semver label
  • Loading branch information
daslerr authored Nov 30, 2024
2 parents 17c0059 + 6b34cc3 commit b024b4f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/assign-semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Require semver label before merge

on:
pull_request:
types: [opened, edited, labeled, unlabeled, synchronize]

jobs:
require-label:
runs-on: ubuntu-latest

steps:
- name: Check for required labels
uses: actions/github-script@v6
with:
script: |
const requiredLabels = ['Semver-Major', 'Semver-Minor', 'Semver-Patch'];
const labels = context.payload.pull_request.labels.map(label => label.name);
const hasRequiredLabel = requiredLabels.some(label => labels.includes(label));
if (!hasRequiredLabel) {
core.setFailed(`Pull request must have one of the following labels: ${requiredLabels.join(', ')}`);
}

0 comments on commit b024b4f

Please sign in to comment.