-
Notifications
You must be signed in to change notification settings - Fork 4
30 lines (25 loc) · 1 KB
/
check-labels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
name: Check labels
on:
workflow_call:
secrets:
github-token:
required: true
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Check Labels
shell: python
run: |
import json
import os
import subprocess
required_labels = set(["breaking-change", "bug", "dependencies", "documentation", "enhancement", "new feature", "internal"])
out = subprocess.check_output(["gh", "pr", "view", "${{ github.event.pull_request.number }}", "--json", "labels", "--repo", "${{ github.repository }}"])
pr_labels = set([label["name"] for label in json.loads(out).get("labels")])
if pr_labels.intersection(required_labels):
exit(0)
subprocess.run(["gh", "pr", "comment", "--repo", "${{ github.repository }}", "${{ github.event.pull_request.number }}", "-b", f"PR missing one of the required labels: **{required_labels}**"])
exit(1)
env:
GH_TOKEN: ${{ secrets.github-token }}