Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/content/docs/reference/cross-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ When `allowed-repos` is specified:
- Target repository (from `target-repo` or current repo) is always implicitly allowed
- Creates a union of allowed destinations

### Checkout Requirement for `push-to-pull-request-branch`

Unlike other safe output types, `push-to-pull-request-branch` with `target-repo` requires the target repository to be **checked out into the workflow workspace** using the `checkout:` frontmatter field with a `path:` specified. Without a checkout, the agent has no local git history to create and push a patch from.

See the [Scheduled Push to Pull-Request Branch](#example-scheduled-push-to-pull-request-branch) example and the [Push to PR Branch cross-repo usage](/gh-aw/reference/safe-outputs-pull-requests/#cross-repo-usage) documentation for a complete setup.

## Examples

### Example: Monorepo Development
Expand Down
25 changes: 25 additions & 0 deletions docs/src/content/docs/reference/safe-outputs-pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,35 @@ safe-outputs:
ignore-missing-branch-failure: false # treat deleted/missing branch errors as skipped instead of failed (default: false)
check-branch-protection: true # set to false to skip the branch protection pre-flight check (default: true)
protected-files: fallback-to-issue # create review issue if protected files modified
target-repo: "owner/repo" # cross-repository (target repo must be checked out)
allowed-repos: ["org/repo1"] # additional allowed repositories
```

When `push-to-pull-request-branch` is configured, git commands (`checkout`, `branch`, `switch`, `add`, `rm`, `commit`, `merge`) are automatically enabled.

### Cross-repo usage

`push-to-pull-request-branch` supports pushing to pull requests in a different repository via `target-repo` (and optionally `allowed-repos`). When `target-repo` is set, **the target repository must be checked out into the workflow workspace** using the `checkout:` frontmatter field with a `path:` specified.

```yaml wrap
checkout:
- fetch-depth: 0 # checkout current (source) repo
- repository: org/target-repo
path: ./target-repo # must set path for cross-repo checkout
github-token: ${{ secrets.CROSS_REPO_PAT }}
fetch: ["refs/pulls/open/*"] # fetch all open PR branches

Comment on lines +279 to +284
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

In the cross-repo example, the org/target-repo checkout uses fetch: ["refs/pulls/open/*"] but does not set fetch-depth: 0. The checkout reference docs recommend fetch-depth: 0 when fetching additional refs to ensure full history/PR details are available; with a shallow clone the push-to-PR flow may not have enough history to inspect or apply changes reliably. Consider adding fetch-depth: 0 to the target repo checkout entry as well.

Copilot uses AI. Check for mistakes.
safe-outputs:
github-token: ${{ secrets.CROSS_REPO_PAT }}
push-to-pull-request-branch:
target-repo: "org/target-repo"
title-prefix: "[bot] "
```

The `path:` field is required so the agent knows where the target repository is mounted in the workspace. Without a `path`, the checkout action writes to the root of the workspace and overwrites the source repository, which will cause the workflow to fail.

See [Cross-Repository Operations](/gh-aw/reference/cross-repository/) for a complete example and documentation on `target-repo`, `allowed-repos`, and cross-repository authentication.

Like `create-pull-request`, pushes with GitHub Agentic Workflows do not trigger CI. See [Triggering CI](/gh-aw/reference/triggering-ci/) for how to enable automatic CI triggers.

## Add Reviewer (`add-reviewer:`)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/safe-outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The agent requests issue creation; a separate job with `issues: write` creates i
- [**Reply to PR Review Comment**](/gh-aw/reference/safe-outputs-pull-requests/#reply-to-pr-review-comment-reply-to-pull-request-review-comment) (`reply-to-pull-request-review-comment`) - Reply to existing review comments (max: 10)
- [**Resolve PR Review Thread**](/gh-aw/reference/safe-outputs-pull-requests/#resolve-pr-review-thread-resolve-pull-request-review-thread) (`resolve-pull-request-review-thread`) - Resolve review threads after addressing feedback (max: 10)
- [**Add Reviewer**](/gh-aw/reference/safe-outputs-pull-requests/#add-reviewer-add-reviewer) (`add-reviewer`) - Add reviewers to pull requests (max: 3)
- [**Push to PR Branch**](/gh-aw/reference/safe-outputs-pull-requests/#push-to-pr-branch-push-to-pull-request-branch) (`push-to-pull-request-branch`) - Push changes to PR branch (default max: 1, configurable, same-repo only)
- [**Push to PR Branch**](/gh-aw/reference/safe-outputs-pull-requests/#push-to-pr-branch-push-to-pull-request-branch) (`push-to-pull-request-branch`) - Push changes to PR branch (default max: 1, configurable; cross-repo supported via `target-repo` when the target repository is checked out)

### Labels, Assignments & Reviews

Expand Down
Loading