-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (63 loc) · 2.15 KB
/
dependabot-differ.yaml
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
# Do NOT use any secrets in this workflow. This will result in serious security holes.
name: Dependabot Diff Checker
on:
pull_request_target:
types:
- labeled
jobs:
dependabot_diff:
name: Site Build Difference
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'dependencies') # See https://git.io/JsVv1
steps:
- name: Checkout Pull Request Branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: true
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Build Pull Request Version of Website
run: |
bundle install
bundle exec jekyll build
mv _site _site-pr
- name: Checkout Default Branch
uses: actions/checkout@v4
with:
clean: false
submodules: true
- name: Build Production Version of Website
run: |
bundle install
bundle exec jekyll build
- name: Compare Built Websites
id: site-diff
run: |
has_changes=0
site_diff=$(diff -r _site-pr _site) || has_changes=$?
if [[ $has_changes == 0 ]]; then
PR_COMMENT="
There were no changes to the code of the compiled website as a result of this Dependabot update.
"
else
PR_COMMENT="
There were changes to the compiled website as a result of this Dependabot update:
\`\`\`
$site_diff
\`\`\`
"
fi
# Replace newlines and other special characters with escaped equivalents
PR_COMMENT="${PR_COMMENT//'%'/'%25'}"
PR_COMMENT="${PR_COMMENT//$'\n'/'%0A'}"
PR_COMMENT="${PR_COMMENT//$'\r'/'%0D'}"
echo "::set-output name=pr-comment::$PR_COMMENT"
- name: Comment on the Pull Request
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.site-diff.outputs.pr-comment }}