Skip to content

Create require-label.yml #1

Create require-label.yml

Create require-label.yml #1

Workflow file for this run

name: Require Label
on:
pull_request:
types: [opened, edited, labeled, unlabeled, synchronize]
jobs:
check-label:
runs-on: ubuntu-latest
steps:
- name: Check for Label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const requiredLabels = ['housekeeping', 'feature', 'bug-fix', 'dependencies'];
const labels = context.payload.pull_request.labels.map(label => label.name);
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label));
if (!hasRequiredLabel) {
core.setFailed(`The PR must have at least one of the following labels: ${requiredLabels.join(', ')}.`);
}