Skip to content

Implement the Tudor crown in the Header component (v5.x) #166

Implement the Tudor crown in the Header component (v5.x)

Implement the Tudor crown in the Header component (v5.x) #166

name: Diff changes to dist
on:
pull_request:
paths: ['dist/**']
permissions:
pull-requests: write
jobs:
generate-diff:
name: Generate diff
runs-on: ubuntu-latest
# Skip when token write permissions are unavailable on forks
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v4.1.1
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
git config diff.mincss.textconv js-beautify
- name: Generate diff
id: 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 distribution diffs
uses: actions/upload-artifact@v3.1.3
with:
name: Dist diff
path: dist*.diff
if-no-files-found: ignore
- name: Add comment to PR
uses: actions/github-script@v6.4.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 }}/dist-js.diff',
titleText: 'JavaScript changes to `dist`',
markerText: 'dist-diff-js'
},
{
path: '${{ github.workspace }}/dist-css.diff',
titleText: 'Stylesheets changes to `dist`',
markerText: 'dist-diff-css'
},
{
path: '${{ github.workspace }}/dist-other.diff',
titleText: 'Other changes to `dist`',
markerText: 'dist-diff-other'
}
]
await commentDiffs({ github, context, commit }, issueNumber, diffs)