39 lines
1.2 KiB
YAML
39 lines
1.2 KiB
YAML
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
|