Skip to content

Commit 0be9498

Browse files
Fix PR preview responder setting correct origin remote (#2528)
#skip-bb <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2528" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes the PR review responder so pushes go to the PR’s fork instead of the base repo on forked PRs. Exposes the head repository and sets origin’s pushurl to ensure correct push behavior. - **Bug Fixes** - Exposes head_repo from workflow_run (run.head_repository.full_name) for later steps. - Adds a step to set origin’s pushurl to the PR’s head repo using GITHUB_TOKEN, preventing accidental pushes to the base repo after claude-code-action rewrites origin. <sup>Written for commit 9ca4297. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> Co-authored-by: Will Chen <[email protected]>
1 parent 5e6440a commit 0be9498

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/pr-review-responder.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ jobs:
151151
core.setOutput('should_continue', 'true');
152152
core.setOutput('request_count', requestCount);
153153
core.setOutput('current_label', currentLabel);
154+
core.setOutput('head_repo', run.head_repository.full_name);
154155
155156
- name: Checkout repository
156157
if: steps.pr-info.outputs.should_continue == 'true'
@@ -169,6 +170,18 @@ jobs:
169170
id: before-claude
170171
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
171172

173+
- name: Configure push remote for fork PRs
174+
if: steps.pr-info.outputs.should_continue == 'true'
175+
run: |
176+
# claude-code-action overwrites origin's fetch URL to point to dyad-sh/dyad
177+
# (using GITHUB_REPOSITORY which is always the base repo in workflow_run events).
178+
# Setting pushurl separately ensures git push still targets the fork,
179+
# because git uses pushurl over url when both are configured.
180+
git remote set-url --push origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ steps.pr-info.outputs.head_repo }}.git"
181+
echo "Configured pushurl to ${{ steps.pr-info.outputs.head_repo }}"
182+
env:
183+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184+
172185
- name: Update labels to pending
173186
if: steps.pr-info.outputs.should_continue == 'true'
174187
run: |

0 commit comments

Comments
 (0)