forked from celestiaorg/celestia-node
-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (62 loc) · 2.49 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Required Labels and Breaking Change Detection
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize, edited]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
# Check that the PR has required labels
required-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check required labels
uses: mheap/github-action-required-labels@v5
with:
mode: minimum
count: 1
labels: "kind:fix, kind:misc, kind:break!, kind:refactor, kind:feat, kind:deps, kind:docs, kind:ci, kind:chore, kind:testing" # yamllint disable-line rule:line-length
# Check for breaking changes and add 'kind:break!' label if detected
check-breaking:
runs-on: ubuntu-latest
if: |
github.actor != 'dependabot[bot]'
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up GitHub CLI
run: |
sudo apt-get install -y gh
- name: Run breaking change detection script
id: breaking_check
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
continue-on-error: true # This allows the job to continue even if breaking changes are detected
run: |
echo "Base Branch: $BASE_BRANCH"
git fetch origin "$BASE_BRANCH"
make detect-breaking
- name: Check if 'kind:break!' label is already present
id: label_check
if: failure()
run: |
LABEL_EXISTS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels | map(.name) | contains(["kind:break!"])')
echo "Label exists: $LABEL_EXISTS"
echo "label_exists=${{ $LABEL_EXISTS }}" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add 'kind:break!' label if breaking changes detected
if: ${{ failure() && env.label_exists == 'false' }}
run: |
echo "Breaking changes detected, adding 'kind:break!' label to PR #${{ github.event.pull_request.number }}."
gh pr edit ${{ github.event.pull_request.number }} --add-label "kind:break!"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Label already exists or apply failed
if: ${{ failure() && env.label_exists == 'true' }}
run: echo "The 'kind:break!' label already exists or could not be added."