Skip to content

[plan] Fix push_to_pull_request_branch conclusion handler to run git ops in target repo directory #28374

@github-actions

Description

@github-actions

Objective

Fix actions/setup/js/push_to_pull_request_branch.cjs (conclusion handler) to run all git operations (fetch, checkout, apply, push) in the target repo's checkout directory instead of the workspace root.

Context

Issue #21306: The conclusion handler already resolves the target repo slug but then runs git fetch, git checkout, git apply, and git push with no cwd, so they all run in the job's default working directory (workspace root) instead of the subdirectory where the target repo is checked out.

Approach

  1. Add require('./find_repo_checkout.cjs') at the top of the file
  2. After resolving itemRepo (the target repo slug) and before any git commands:
    • If itemRepo differs from process.env.GITHUB_REPOSITORY, call findRepoCheckout(itemRepo, process.env.GITHUB_WORKSPACE, { allowedRepos }). If not found, return { success: false, error: "Repository 'org/repo' not found in workspace..." }.
    • Set repoCwd = checkoutResult.path
  3. Pass { cwd: repoCwd, env: { ...process.env, ...gitAuthEnv } } to every exec.exec call for git (fetch, checkout, apply, push)
    • Prefer explicit cwd per exec call over process.chdir to avoid global state side effects

Files to Modify

  • actions/setup/js/push_to_pull_request_branch.cjs — main push/apply git block

Acceptance Criteria

  • findRepoCheckout is imported and called when target repo differs from GITHUB_REPOSITORY
  • All git commands receive { cwd: repoCwd } option
  • getGitAuthEnv is still applied for fetch/push operations
  • Clear error returned if target repo not found in workspace
  • make agent-finish passes
    Related to Make push_to_pull_request_branch cross-repo #21306

Generated by Plan Command for issue #21306 · ● 147.1K ·

  • expires on Apr 26, 2026, 11:51 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions