Skip to content

feat: added prettier formatter and github workflow to format on PR #3

feat: added prettier formatter and github workflow to format on PR

feat: added prettier formatter and github workflow to format on PR #3

Workflow file for this run

name: "auto-format"
on:
pull_request:
branches: [main]
jobs:
format:
name: format code with prettier
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: setup node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- name: install dependencies
run: npm ci
- name: run prettier
run: npm run format
- name: commit and push if changed
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
if ! git diff --staged --quiet; then
git commit -m "style: auto-format code with Prettier"
git push
else
echo "No formatting changes needed"
fi