-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (81 loc) · 3.18 KB
/
changeset-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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: PR Changeset Check
on:
pull_request_target:
types:
- opened
- synchronize
permissions:
contents: read
jobs:
check_changeset:
runs-on: ubuntu-latest
permissions:
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Changed Files
id: changed-files
uses: tj-actions/[email protected]
with:
files: |
.changeset/**.md
- name: Check for major changes
id: check_changeset
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
GH_TOKEN: ${{ github.token }}
run: |
# Pull PR source branch code
files=$ALL_CHANGED_FILES
echo "File list: $files"
diff=$(gh pr diff ${{ github.event.pull_request.number }})
if echo $diff | grep $ALL_CHANGED_FILES -A 8 | grep "major"; then
major_changes=$(gh pr diff ${{ github.event.pull_request.number }} | grep $ALL_CHANGED_FILES -A 8 | grep "major")
echo "Found major changes."
echo "comment=$major_changes" >> $GITHUB_OUTPUT
else
echo "Not found major changes."
comment=""
echo "comment=$comment" >> $GITHUB_OUTPUT
fi
- name: Add label
if: ${{ steps.check_changeset.outputs.comment != '' }}
uses: actions-cool/issues-helper@v3
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
labels: 'major'
- name: update status comment
if: ${{ steps.check_changeset.outputs.comment != '' }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
## 🚨 @${{ github.actor }}, The changes in this PR include major changes, please confirm whether they meet expectations。
___
## 🚨 @${{ github.actor }}, this PR contains major changes, please confirm if it is as expected.
```diff
${{ steps.check_changeset.outputs.comment }}
```
<!-- AUTO_CHANGESET_CHECK_HOOK -->
body-include: '<!-- AUTO_CHANGESET_CHECK_HOOK -->'
number: ${{ github.event.pull_request.number }}
- name: Delete comment
if: ${{ steps.check_changeset.outputs.comment == '' }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body-include: '<!-- AUTO_CHANGESET_CHECK_HOOK -->'
number: ${{ github.event.pull_request.number }}
delete: true
- name: Remove labels
if: ${{ steps.check_changeset.outputs.comment == '' }}
uses: actions-cool/issues-helper@v3
with:
actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
labels: 'major'