Skip to content

Commit

Permalink
Updated prettier workflows
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 22, 2024
1 parent b2ee83a commit 435ddf9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/prettier-comment-on-pr.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
name: Prettier code formatter
name: Prettier code formatter (PR)

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
check:
Expand All @@ -32,17 +28,19 @@ jobs:
git diff -- . ':(exclude)package-lock.json' ':(exclude)package.json' > diff.txt
npm install -g diff2html-cli
diff2html -i file -s side -F diff.html -- diff.txt
- name: Upload html diff
id: artifact-upload-step
- name: Upload html diff ⬆️
id: artifact-upload
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: HTML_Diff
name: HTML Diff
path: diff.html
retention-days: 3
- name: Dispatch information to repository
if: ${{ failure() && steps.prettier.conclusion == 'failure' && github.event_name == 'pull_request' }}
uses: peter-evans/repository-dispatch@v2
retention-days: 7
- name: PR comment with diff 💬
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
uses: thollander/actions-comment-pull-request@v2
with:
event-type: prettier-failed-on-pr
client-payload: '{"pr_number": "${{ github.event.number }}", "artifact_url": "${{ steps.artifact-upload-step.outputs.artifact-url }}"}'
comment_tag: prettier-failed
message: |
Failed [prettier code check](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
Check [this file](${{ steps.artifact-upload.outputs.artifact-url }}) for more information.
38 changes: 38 additions & 0 deletions .github/workflows/prettier-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Prettier code formatter (push)

on:
push:
branches:
- master
- main

jobs:
check:
# available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Setup Node.js ⚙️
uses: actions/setup-node@v4
- 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: Create diff 📝
# https://docs.github.com/en/actions/learn-github-actions/expressions#failure
if: ${{ failure() }}
run: |
npx prettier . --write
git diff -- . ':(exclude)package-lock.json' ':(exclude)package.json' > diff.txt
npm install -g diff2html-cli
diff2html -i file -s side -F diff.html -- diff.txt
- name: Upload html diff ⬆️
id: artifact-upload
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: HTML Diff
path: diff.html
retention-days: 7

0 comments on commit 435ddf9

Please sign in to comment.