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 title and labels #4902

Open
wants to merge 1 commit 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.

37 changes: 37 additions & 0 deletions .github/workflows/check-title-and-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# based on https://stackoverflow.com/a/75036059 and
# https://github.com/astropy/astropy/blob/main/.github/workflows/check_milestone.yml
name: Check PR title and labels

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

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

jobs:
check-title:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
if (/^\[?WIP\b/i.test(context.payload.pull_request.title)) {
core.setFailed("WIP pull requests can't be merged.");
}

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