Skip to content

Commit

Permalink
Prettier check now generates a diff comment on PR
Browse files Browse the repository at this point in the history
Signed-off-by: George Araújo <[email protected]>
  • Loading branch information
george-gca committed Jan 16, 2024
1 parent f669b23 commit f8b7f8e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Prettier code formatter




on:
push:
branches:
Expand All @@ -23,4 +26,20 @@ jobs:
- name: Install Prettier 💾
run: npm install --save-dev --save-exact prettier @shopify/prettier-plugin-liquid
- name: Prettier Check 🔎
id: prettier
run: npx prettier . --check
- name: Show diff 📝
# https://docs.github.com/en/actions/learn-github-actions/expressions#failure
if: ${{ failure() }}
run: |
npx prettier . --write
git diff > diff.txt
npm install -g diff2html-cli
diff2html -i file -s side -F diff.html -- diff.txt
echo "::set-output name=diff::$(cat diff.html)"
- name: PR comment with file
# https://docs.github.com/en/actions/learn-github-actions/expressions#failure-with-conditions
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
uses: thollander/actions-comment-pull-request@v2
with:
filePath: diff.html

0 comments on commit f8b7f8e

Please sign in to comment.