Skip to content

Commit c5b4bf2

Browse files
authored
docs: add working-directory navigation example to side-repo-ops pattern (#26123)
1 parent 6096c38 commit c5b4bf2

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

docs/src/content/docs/patterns/side-repo-ops.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,47 @@ safe-outputs:
440440
Work on user-specified repository: {{inputs.target_repo}}
441441
```
442442

443+
### Checking Out the Target Repository
444+
445+
When your workflow needs to run local tools against the target repository (for example, running tests, linters, or build scripts), check it out to a named path and explicitly navigate the agent into that directory:
446+
447+
```aw wrap
448+
---
449+
on:
450+
workflow_dispatch:
451+
inputs:
452+
target_repo:
453+
description: "Target repository (owner/repo)"
454+
required: true
455+
456+
checkout:
457+
- repository: ${{ github.event.inputs.target_repo }}
458+
path: repo
459+
github-token: ${{ secrets.GH_AW_MAIN_REPO_TOKEN }}
460+
current: true
461+
462+
engine: copilot
463+
464+
permissions:
465+
contents: read
466+
467+
safe-outputs:
468+
github-token: ${{ secrets.GH_AW_MAIN_REPO_TOKEN }}
469+
create-pull-request:
470+
target-repo: ${{ inputs.target_repo }}
471+
base-branch: main
472+
---
473+
474+
# Run Tests in Target Repository
475+
476+
Navigate into the folder where the target repository has been checked out into: cd ${{ github.workspace }}/repo
477+
478+
Run the test suite and report any failures.
479+
```
480+
481+
> [!IMPORTANT]
482+
> `current: true` tells the agent which repository to treat as its primary target for GitHub operations — it does **not** automatically set the working directory. Without the explicit `cd` instruction in the prompt, the agent starts in `$GITHUB_WORKSPACE` (the side repository checkout) and must infer the correct directory on its own, which can lead to mistakes.
483+
443484
### Using GitHub Apps
444485

445486
For enhanced security, use GitHub Apps instead of PATs.

docs/src/content/docs/reference/checkout.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ checkout:
119119
current: true # agent's primary target
120120
```
121121

122+
> [!IMPORTANT]
123+
> `current: true` only annotates the agent's system prompt to identify the target repository — it does **not** automatically change the working directory. If the agent needs to run local tools (tests, linters, build scripts) against the checked-out repository, add an explicit `cd` instruction to the prompt:
124+
>
125+
> ```
126+
> Navigate into the folder where the target repository has been checked out into: cd ${{ github.workspace }}/target
127+
> ```
128+
>
129+
> Without this instruction, the agent starts in `$GITHUB_WORKSPACE` (the side repository checkout) and must infer the correct directory on its own.
130+
122131
## Checkout Merging
123132

124133
Multiple `checkout:` configurations can target the same path and repository. This is useful for monorepos where different parts of the repository must be merged into the same workspace directory with different settings (e.g., sparse checkout for some paths, full checkout for others).

0 commit comments

Comments
 (0)