-
Notifications
You must be signed in to change notification settings - Fork 1.2k
46 lines (39 loc) · 1.32 KB
/
major-version-check.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
name: Major version in changeset
on:
pull_request:
branches:
- main
types:
- labeled
- unlabeled
- opened
- synchronize
- reopened
jobs:
check-changesets:
if: |
!contains(github.event.pull_request.labels.*.name, '🤖Skip Major Check')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Fetch all branches
run: git fetch --all
- name: Checkout the feature branch
run: git checkout "$GITHUB_HEAD_REF" --
- name: Check major versions in changeset entries
run: |
commits="origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF"
changeset_files=$(git diff --name-only --diff-filter=d "$commits" -- ".changeset/*.md")
if [[ -z "$changeset_files" ]]; then
echo "No changeset files detected"
exit 0
fi
if ! echo "$changeset_files" | xargs grep -qE "^\s*[\"'].*?[\"']\s*:\s*major\s*$"; then
echo "No major version upgrade detected"
exit 0
else
echo "This PR contains a major version upgrade which is only used for breaking changes."
echo "If you are sure you want to perform this action, please add the '🤖Skip Major Check' label"
exit 1
fi