diff --git a/.github/workflows/assign-semver.yml b/.github/workflows/assign-semver.yml new file mode 100644 index 000000000..4e3528a63 --- /dev/null +++ b/.github/workflows/assign-semver.yml @@ -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(', ')}`); + } \ No newline at end of file