Skip to content

Commit

Permalink
Add GH actions workflow to check PR labels
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 committed May 10, 2024
1 parent 8d58839 commit a227d77
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/check-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# based on https://stackoverflow.com/a/75036059 and
# https://github.com/astropy/astropy/blob/main/.github/workflows/check_milestone.yml
name: Check PR labels

on:
# So it cannot be skipped.
pull_request_target:
types: [opened, synchronize, labeled, unlabeled]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const requiredLabels = ['bug', 'enhancement', 'new feature', 'docs', 'infrastructure', 'dead code', 'refactor'];
let labels = context.payload.pull_request.labels;
core.info(`Current labels: ${labels.map(l => l.name).join(', ')}`);
if (labels.filter(l => requiredLabels.includes(l.name)).length === 0) {
core.setFailed('Please label this pull request with one of: bug, enhancement, new feature, docs or infrastructure.');
}

0 comments on commit a227d77

Please sign in to comment.