-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GH actions workflow to replace mergeable bot
- Loading branch information
Showing
2 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | ||
} |