ci(prettier): make workflow check-only instead of auto-committing (#2356)

Convert the Prettier workflow from auto-formatting and pushing commits
back to the PR branch into a check-only job. It now runs
`prettier@3 --check .`, which annotates and fails on unformatted files
but never writes, commits, or pushes anything. Drops the auto-commit
step and narrows permissions to `contents: read`.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Harshit Singh Bhandari 2026-07-02 22:49:29 +05:30 committed by GitHub
parent 6186458df7
commit e56248759e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 21 deletions

View File

@ -1,11 +1,10 @@
name: Prettier name: Prettier
# Auto-formats the codebase on every push and commits the result back. # Check-only: reports formatting issues without modifying the branch.
# Formatting is a CI concern — developers never need to run Prettier locally # The job fails (and annotates unformatted files) when `prettier --check`
# and formatted output never shows up as local uncommitted changes. # finds files that are not formatted, but it never writes, commits, or
# # pushes anything back to the PR. Developers run `npx prettier@3 --write .`
# GitHub Actions does not re-trigger workflows on commits made with GITHUB_TOKEN, # locally to fix the reported files.
# so there is no feedback loop risk.
on: on:
push: push:
@ -18,21 +17,9 @@ jobs:
format: format:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: read
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Format with Prettier - name: Check formatting with Prettier
run: npx --yes prettier@3 --write . run: npx --yes prettier@3 --check .
- name: Commit formatted files
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git diff --quiet && exit 0
git add -A
git commit -m "chore: format with prettier [skip ci]"
git push