Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GH actions workflow to check PR labels #4902

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/mergeable.yml

This file was deleted.

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.head_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.');
}
Loading