Skip to content

Commit

Permalink
Add workflow for ensuring PRs are labeled (#3056)
Browse files Browse the repository at this point in the history
* Add workflow for ensuring PRs are labeled

* use required labels instead
  • Loading branch information
jennaleeb committed Jan 27, 2023
1 parent b67e6d5 commit 8763c17
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ensure_pull_requests_are_labeled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Ensure pull requests are labelled
on:
pull_request:
types: [opened, labeled, unlabeled]

jobs:
label_pull_requests:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/github-script@v6
with:
script: |
const {data: labels} = await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
console.log(labels)
const requiredLabels = ["security", "feature", "bug", "perf", "refactor", "maintenance", "docs"]
const labelsPresent = labels.some((label) => requiredLabels.includes(label.name))
if (!labelsPresent) {
throw new Error(`All pull requests require at least one of the required labels ${requiredLabels}`)
}

0 comments on commit 8763c17

Please sign in to comment.