Skip to content

Commit 917722a

Browse files
committed
Add GH actions workflow to replace mergeable bot
1 parent 9ba75d1 commit 917722a

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

.github/mergeable.yml

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# based on https://stackoverflow.com/a/75036059 and
2+
# https://github.com/astropy/astropy/blob/main/.github/workflows/check_milestone.yml
3+
name: Check PR title and labels
4+
5+
on:
6+
# So it cannot be skipped.
7+
pull_request_target:
8+
types: [opened, edited, synchronize, labeled, unlabeled]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.head_ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-title:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/github-script@v7
19+
with:
20+
script: |
21+
if (/^\[?WIP\b/i.test(context.payload.pull_request.title)) {
22+
core.setFailed("WIP pull requests can't be merged.");
23+
}
24+
25+
check-labels:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/github-script@v7
29+
with:
30+
script: |
31+
const requiredLabels = ['bug', 'enhancement', 'new feature', 'docs', 'infrastructure', 'dead code', 'refactor'];
32+
let labels = context.payload.pull_request.labels;
33+
34+
core.info(`Current labels: ${labels.map(l => l.name).join(', ')}`);
35+
if (labels.filter(l => requiredLabels.includes(l.name)).length === 0) {
36+
core.setFailed('Please label this pull request with one of: bug, enhancement, new feature, docs or infrastructure.');
37+
}

0 commit comments

Comments
 (0)