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:
parent
6186458df7
commit
e56248759e
|
|
@ -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 .
|
||||
|
|
|
|||
Loading…
Reference in New Issue