|
| 1 | +name: Diff chart changes |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, reopened, edited, 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 | + - run: | |
| 57 | + mkdir base head |
| 58 | +
|
| 59 | + mv base-r/rendered-charts/* base/ |
| 60 | + mv head-r/rendered-charts/* head/ |
| 61 | +
|
| 62 | + DIFF=$(diff -r base/ head/) |
| 63 | +
|
| 64 | + if [ -z "$DIFF" ]; then |
| 65 | + cat <<EOF > pr.md |
| 66 | + No changes detected in rendered charts. |
| 67 | + EOF |
| 68 | + else |
| 69 | + cat <<EOF > pr.md |
| 70 | + This PR results in the following changes to rendered charts: |
| 71 | +
|
| 72 | + ```diff |
| 73 | + ${DIFF} |
| 74 | + ``` |
| 75 | + EOF |
| 76 | + fi |
| 77 | +
|
| 78 | + gh pr comment "${{github.event.pull_request.html_url}}" --create-if-none --edit-last --body-file pr.md |
0 commit comments