-
Notifications
You must be signed in to change notification settings - Fork 196
98 lines (85 loc) · 2.71 KB
/
diff.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
95
96
97
98
# Posts a comment listing all the colors that changed in a PR
name: Diff
on:
pull_request:
branches-ignore:
- 'test/**'
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Create comment (if necessary)
uses: actions/github-script@v5
with:
script: |
const fs = require('fs')
const body = fs.readFileSync('.github/diff_comment_template.md', 'utf8')
const result = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
console.log(result.data)
const botComments = result.data.filter(c => c.user.login === 'github-actions[bot]')
if (!botComments.length) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
}
diff:
needs: comment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout base branch
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
path: base
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
- name: Install dependencies (base)
run: pushd base; yarn; popd
- name: Build (base)
run: pushd base; yarn build; popd
- name: Diff
uses: primer/comment-token-update@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: github-actions[bot]
with:
# This action will find the first comment by `github-actions[bot]` and
# insert the diff data if `<!-- diff --><!-- /diff -->` is present in that comment.
# If there are multiple comments by `github-actions[bot]`
# or if `<!-- diff --><!-- /diff -->` is missing,
# this action may not work as expected.
comment-token: 'diff'
script: |
diff=$(for file in themes/*.json
do
diff -U 1 base/$file $file
done)
echo "\`\`\`diff"
if [[ $diff ]]
then
echo "$diff"
else
echo "No colors changed"
fi
echo "\`\`\`"