Skip to content

fix: enable Prettier GitHub Action to auto-commit formatting changes#153

Open
vansh2408 wants to merge 1 commit intoidna001:masterfrom
vansh2408:fix/prettier-auto-commit-action
Open

fix: enable Prettier GitHub Action to auto-commit formatting changes#153
vansh2408 wants to merge 1 commit intoidna001:masterfrom
vansh2408:fix/prettier-auto-commit-action

Conversation

@vansh2408
Copy link
Copy Markdown
Contributor

Summary

Fixes the Prettier GitHub Action to successfully commit and push formatting changes back to pull request branches.

Related Issue

Closes #151

Problem

The Prettier action was running successfully and detecting formatting issues, but failing to commit and push the fixes back to the PR branch. Changes remained local to the CI environment and were never persisted.

Solution

This PR implements several critical fixes:

Changes Made

  • Added Explicit Permissions
    Added contents: write permission to allow pushing commits
    Added pull-requests: write permission for PR comments
  • Fixed Branch Checkout
    Changed checkout ref to ${{ github.head_ref || github.ref }}
    Ensures we checkout the actual PR branch, not a merge commit
  • Corrected Push Command
    Updated to git push origin HEAD:${{ github.head_ref || github.ref_name }}
    Explicitly targets the correct branch reference

Additional Notes

Fork PRs: Due to GitHub security restrictions, this action cannot automatically commit to PRs from forked repositories. For fork PRs, consider:

  • Requesting contributors open PRs from branches in the main repo
  • Adding a separate workflow that comments on fork PRs requesting manual formatting

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 11, 2025

@vansh2408 is attempting to deploy a commit to the idna001's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Owner

@idna001 idna001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR. Right now, the Action fails on another step. It don't finds the PR.
What is it about?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧩 Prettier GitHub Action does not commit fixes automatically

2 participants