Fix prettier workflow for fork PRs#90
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9baca1040e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
.github/workflows/prettier.yaml
Outdated
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} |
There was a problem hiding this comment.
Use branch ref for push checkout
On push events this ref expression resolves to github.sha, which checks out a detached HEAD; the following creyD/prettier_action step is expected to create and push a formatting commit back to main, and detached checkouts commonly fail branch-based pushes when changes are present. This means auto-formatting on push can break even though the workflow intends to keep that behavior for main.
Useful? React with 👍 / 👎.
Problem
The prettier workflow uses
ref: ${{ github.head_ref }}which tries to checkout the PR branch from the base repository. For PRs from forks, this fails because the branch only exists in the contributor's fork.Solution
prettier --check(read-only, no commit needed)creyD/prettier_actionThis way fork PRs can be validated without needing write access to the fork.