Skip to content

Commit

Permalink
Add GH actions workflow to replace mergeable bot
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 committed Nov 12, 2024
1 parent 9ba75d1 commit 917722a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
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.');
}

0 comments on commit 917722a

Please sign in to comment.