-
Notifications
You must be signed in to change notification settings - Fork 1.2k
52 lines (43 loc) · 1.54 KB
/
migrator-comment.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
name: Migrator comment in diff
on:
pull_request:
types:
- labeled
- unlabeled
- opened
- synchronize
- reopened
env:
COMMENT: 'generated by polaris-migrator DO NOT COPY'
jobs:
check-diff:
if: |
!contains(github.event.pull_request.labels.*.name, '🤖Skip Comment 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 for generic migrator comment in diff
run: |
commits="origin/${{ github.base_ref }}...origin/${{ github.head_ref }}"
files=$(git diff --name-only --diff-filter=d "$commits" -- "*.scss")
if [ -n "$files" ]; then
echo "SCSS files where modified."
echo "$files"
else
echo "No SCSS files where modified."
exit 0
fi
filesWithComment=$(git diff --unified=0 --diff-filter=d "$commits" -- $(echo $files) | grep "^\+.*$COMMENT" || true)
if [ -n "$filesWithComment" ]; then
echo "A migrator comment '$COMMENT' was added to a SCSS file in this PR."
echo "Please provide a description for any Stylelint disable comments."
echo "If this is not applicable, you can add the '🤖Skip Comment Check' label to this PR."
exit 1
else
echo "All good, no migrator comments were added."
fi