Skip to content

Commit

Permalink
Merge pull request #2244 from alphagov/ldeb-fix-diff-change-to-dist
Browse files Browse the repository at this point in the history
Fix diff changes to dist GitHub Action
  • Loading branch information
lfdebrux authored Jun 4, 2021
2 parents 781f0a7 + 8f26b79 commit 7416216
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/diff-change-to-dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ jobs:
- name: Generate diff
id: diff
run: |
diff=$(git diff -M1 origin/$GITHUB_BASE_REF -- dist)
# Escape new lines
diff="${diff//'%'/'%25'}"
diff="${diff//$'\n'/'%0A'}"
diff="${diff//$'\r'/'%0D'}"
echo "::set-output name=diff::$diff"
git diff -M05 origin/$GITHUB_BASE_REF -- dist \
> $GITHUB_WORKSPACE/dist.diff
- name: Add comment to PR
uses: actions/github-script@v3
env:
DIFF: ${{ steps.diff.outputs.diff }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const commentText = '## Changes to dist\n' +
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' +
process.env.DIFF +
diff +
'\n```'
github.issues.createComment({
Expand Down

0 comments on commit 7416216

Please sign in to comment.