Skip to content

Commit c12232a

Browse files
committed
Add chart diffing GHA workflow
1 parent f397f89 commit c12232a

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

.github/workflows/diff-changes.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Diff chart changes
2+
on:
3+
pull_request:
4+
types: [opened, reopened, synchronize]
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.ref_name }}
7+
cancel-in-progress: false
8+
9+
jobs:
10+
render-charts-base:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
ref: ${{ github.event.pull_request.base.ref }}
17+
show-progress: false
18+
- name: Run govuk-app-render
19+
run: ./govuk-app-render.sh
20+
- name: Archive rendered charts
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: rendered-charts-base
24+
path: output/
25+
retention-days: 1
26+
render-charts-head:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
ref: ${{ github.event.pull_request.head.ref }}
33+
show-progress: false
34+
- name: Run govuk-app-render
35+
run: ./govuk-app-render.sh
36+
- name: Archive rendered charts
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: rendered-charts-head
40+
path: output/
41+
retention-days: 1
42+
diff-charts:
43+
runs-on: ubuntu-latest
44+
needs: [render-charts-base, render-charts-head]
45+
permissions:
46+
pull-requests: write
47+
steps:
48+
- uses: actions/download-artifact@v4
49+
with:
50+
name: rendered-charts-base
51+
path: base-r/
52+
- uses: actions/download-artifact@v4
53+
with:
54+
name: rendered-charts-head
55+
path: head-r/
56+
- name: Diff charts and comment on PR
57+
env:
58+
GH_TOKEN: ${{ github.token }}
59+
run: |
60+
mkdir base head
61+
62+
mv base-r/rendered-charts/* base/
63+
mv head-r/rendered-charts/* head/
64+
65+
DIFF=$(diff -r base/ head/)
66+
67+
if [ -z "$DIFF" ]; then
68+
cat <<EOF > pr.md
69+
No changes detected in rendered charts.
70+
EOF
71+
else
72+
cat <<EOF > pr.md
73+
<details>
74+
<summary>Rendered charts diff</summary>
75+
This PR results in the following changes to rendered charts:
76+
77+
```diff
78+
${DIFF}
79+
```
80+
</details>
81+
EOF
82+
fi
83+
84+
gh pr comment "${{github.event.pull_request.html_url}}" --create-if-none --edit-last --body-file pr.md

0 commit comments

Comments
 (0)