From e56248759ef41dd5330d7d66ce36e70572a404f3 Mon Sep 17 00:00:00 2001 From: Harshit Singh Bhandari Date: Thu, 2 Jul 2026 22:49:29 +0530 Subject: [PATCH] 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 --- .github/workflows/prettier.yml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index b9a10b8df..5dbea5388 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,11 +1,10 @@ name: Prettier -# Auto-formats the codebase on every push and commits the result back. -# Formatting is a CI concern — developers never need to run Prettier locally -# and formatted output never shows up as local uncommitted changes. -# -# GitHub Actions does not re-trigger workflows on commits made with GITHUB_TOKEN, -# so there is no feedback loop risk. +# Check-only: reports formatting issues without modifying the branch. +# The job fails (and annotates unformatted files) when `prettier --check` +# finds files that are not formatted, but it never writes, commits, or +# pushes anything back to the PR. Developers run `npx prettier@3 --write .` +# locally to fix the reported files. on: push: @@ -18,21 +17,9 @@ jobs: format: runs-on: ubuntu-latest permissions: - contents: write + contents: read steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - token: ${{ secrets.GITHUB_TOKEN }} - - name: Format with Prettier - run: npx --yes prettier@3 --write . - - - 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 + - name: Check formatting with Prettier + run: npx --yes prettier@3 --check .