Release v4.9.0 #187
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Diff changes to dist | |
on: | |
pull_request: | |
paths: ['dist/**'] | |
permissions: | |
pull-requests: write | |
jobs: | |
generate-diff: | |
name: Generate Diff | |
runs-on: ubuntu-latest | |
# Abort if run from a fork, as token won't have write access to post comment | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
steps: | |
- uses: actions/[email protected] | |
with: | |
fetch-depth: 0 # Need to also checkout the base branch to compare | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
with: | |
cache: npm | |
node-version-file: .nvmrc | |
- 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: | | |
git diff -M05 origin/$GITHUB_BASE_REF -- dist \ | |
> $GITHUB_WORKSPACE/dist.diff | |
- name: Add comment to PR | |
uses: actions/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs').promises | |
const diff = await fs.readFile( | |
process.env.GITHUB_WORKSPACE + '/dist.diff', 'utf8' | |
) | |
const commentText = '## Changes to dist\n' + | |
'```diff\n' + | |
diff + | |
'\n```' | |
github.rest.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentText | |
}) |