Skip to content

Commit f5d091f

Browse files
committed
Fix lint workflow for fork PRs
The lint workflow uses pull_request_target which can't fetch fork branches by ref name. Switch to checking out by SHA with the fork's repository, which works for both forks and same-repo PRs. Skip the auto-push step for fork PRs since we can't push to external repos.
1 parent f5604b9 commit f5d091f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v6.0.2
1717
with:
18-
ref: ${{ github.event.pull_request.head.ref || github.ref }}
18+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
19+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
1920

2021
- name: Setup Ruby
2122
uses: ruby/setup-ruby@v1.299.0
@@ -38,8 +39,9 @@ jobs:
3839
fi
3940
4041
- name: Commit and push changes
41-
if: env.changes == 'true'
42+
if: env.changes == 'true' && github.event.pull_request.head.repo.full_name == github.repository
4243
run: |
44+
git checkout -b ${{ github.event.pull_request.head.ref }}
4345
git add .
4446
git commit -m "chore: auto-corrected with RuboCop"
45-
git push
47+
git push origin ${{ github.event.pull_request.head.ref }}

0 commit comments

Comments
 (0)