Skip to content

Scanlator filter

Scanlator filter #231

name: Format Commits
# This action works with pushes
on:
workflow_dispatch: {} # Manuall trigger
pull_request:
branches: [main]
paths:
- '**.js'
- '**.html'
- '**.css'
- '**.md'
push:
branches: [main]
paths:
- '**.js'
- '**.html'
- '**.css'
- '**.md'
jobs:
prettier:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm
- name: Prettify code format
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm ci --silent --omit optional
npx prettier --write "**/*.{js,md,html,css}"
if ! $(git diff --quiet); then
git config user.name github-actions
git config user.email [email protected]
git commit -am 'Reformatted file'
git push
if [ ${{ github.event_name }} == 'pull_request' ]; then
gh pr comment ${{ github.event.number }} --body 'Reformatted your code following [our guidelines](https://github.com/Animeboynz/Mihon-Backup-Viewer/blob/main/CONTRIBUTING.md#formatting-your-code).
Remember to `git pull` if you plan to continue working on this PR'
fi
fi