Validate PR Label eca18fac2de29acaa7fbc58e8f7d4a992fbf9ac3 by @renovate[bot] #163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Semantic PR Label | |
run-name: Validate PR Label ${{ github.sha }} by @${{ github.actor }} | |
on: | |
pull_request: | |
types: [opened, edited, synchronize, reopened, labeled, unlabeled] | |
permissions: | |
pull-requests: read | |
jobs: | |
main: | |
name: Semantic PR Label | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for Required Labels | |
uses: actions/github-script@v8 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const requiredLabels = ["none", "patch", "minor", "major"]; | |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}); | |
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label.name)); | |
if (!hasRequiredLabel) { | |
core.setFailed(`PR must have one of the following labels: ${requiredLabels.join(", ")}`); | |
} else { | |
console.log(`PR has a valid label.`); | |
} |