Skip to content

Release v5.4.0

Release v5.4.0 #178

name: Diff changes to GitHub release
on:
pull_request:
paths: ['dist/**']
permissions:
pull-requests: write
jobs:
generate-diff:
name: Generate diff
runs-on: ubuntu-latest
# Skip workflows other than PRs such as merges to `main` but
# also when token write permissions are unavailable on forks
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v4.1.4
with:
fetch-depth: 0 # Need to also checkout the base branch to compare
- name: Install dependencies
uses: ./.github/workflows/actions/install-node
- name: Set up diff drivers
run: |
npm install -g js-beautify
git config diff.minjs.textconv "js-beautify --editorconfig --type js"
git config diff.mincss.textconv "js-beautify --editorconfig --type css"
- name: Generate diff
run: |
# Using `origin/$GITHUB_BASE_REF` to avoid actually checking out the branch
# as all we need is to let Git diff the two references
bin/dist-diff.sh origin/$GITHUB_BASE_REF $GITHUB_WORKSPACE
- name: Save GitHub release diffs
uses: actions/upload-artifact@v4.3.3
with:
name: GitHub release diffs
path: .cache/diff/dist/*.diff
if-no-files-found: ignore
- name: Add comment to PR
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { commentDiffs } = await import('${{ github.workspace }}/.github/workflows/scripts/comments.mjs')
// PR information
const issueNumber = ${{ github.event.pull_request.number }}
const commit = '${{ github.event.pull_request.head.sha }}'
const diffs = [
{
path: '${{ github.workspace }}/.cache/diff/dist/js.diff',
titleText: 'JavaScript changes to GitHub release',
markerText: 'dist/js.diff'
},
{
path: '${{ github.workspace }}/.cache/diff/dist/css.diff',
titleText: 'Stylesheets changes to GitHub release',
markerText: 'dist/css.diff'
},
{
path: '${{ github.workspace }}/.cache/diff/dist/other.diff',
titleText: 'Other changes to GitHub release',
markerText: 'dist/other.diff',
skipEmpty: true
}
]
await commentDiffs({ github, context, commit }, issueNumber, diffs)