Skip to content

Add chart diffing GHA workflow #4

Add chart diffing GHA workflow

Add chart diffing GHA workflow #4

Workflow file for this run

name: Diff chart changes
on:
pull_request:
types: [opened, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.ref_name }}
cancel-in-progress: false
jobs:
render-charts-base:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.base.ref }}
show-progress: false
- name: Run govuk-app-render
run: ./govuk-app-render.sh
- name: Archive rendered charts
uses: actions/upload-artifact@v4
with:
name: rendered-charts-base
path: output/
retention-days: 1
render-charts-head:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
show-progress: false
- name: Run govuk-app-render
run: ./govuk-app-render.sh
- name: Archive rendered charts
uses: actions/upload-artifact@v4
with:
name: rendered-charts-head
path: output/
retention-days: 1
diff-charts:
runs-on: ubuntu-latest
needs: [render-charts-base, render-charts-head]
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
with:
name: rendered-charts-base
path: base-r/
- uses: actions/download-artifact@v4
with:
name: rendered-charts-head
path: head-r/
- name: Diff charts and comment on PR
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir base head
mv base-r/rendered-charts/* base/
mv head-r/rendered-charts/* head/
DIFF=$(diff -r base/ head/)
if [ -z "$DIFF" ]; then
cat <<EOF > pr.md
No changes detected in rendered charts.
EOF
else
cat <<EOF > pr.md
This PR results in the following changes to rendered charts:
```diff
${DIFF}
```
EOF
fi
gh pr comment "${{github.event.pull_request.html_url}}" --create-if-none --edit-last --body-file pr.md