GitHubRepoForker
Fork a GitHub repository from an issue URL and optionally create an issue-specific branch—the first step in AI agent workflows that fix GitHub issues by modifying code.
Key Features
- Parses the repository owner, name, and issue number directly from the GitHub issue URL.
- Creates a new fork or syncs an existing one with the upstream repository.
- Optionally waits for the fork to become available before continuing, with configurable timeout and polling interval.
- Optionally creates a
fix-<issue-number>branch in the fork automatically. - Resolves a
GITHUB_TOKENsecret at runtime, keeping credentials out of the pipeline YAML. - Also available as
GitHubRepoForkerToolfor use with Haystack agents.
Configuration
- Store your GitHub personal access token as a secret named
GITHUB_TOKEN. For instructions, see Create Secrets. - Drag the
GitHubRepoForkercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- Set
auto_synctoTrueto keep existing forks up to date with the upstream. - Set
create_branchtoTrueto generate afix-<issue-number>branch automatically.
Connections
GitHubRepoForker receives a single url (the full GitHub issue URL). It outputs repo (the fork path in owner/repo format) and issue_branch (the name of the created branch, if any). Connect these outputs to GitHubFileEditor or GitHubPRCreator to build a complete issue-resolution pipeline.
Source Code
To check this component's source code, open repo_forker.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
GitHubRepoForker:
type: haystack_integrations.components.connectors.github.repo_forker.GitHubRepoForker
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true
auto_sync: true
create_branch: true
wait_for_completion: false
max_wait_seconds: 300
poll_interval: 2
Using the Component in a Pipeline
This example shows a code-fix agent pipeline that forks a repo from a GitHub issue URL, edits a file in the fork, and opens a pull request.
# haystack-pipeline
components:
repo_forker:
type: haystack_integrations.components.connectors.github.repo_forker.GitHubRepoForker
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
auto_sync: true
create_branch: true
file_editor:
type: haystack_integrations.components.connectors.github.file_editor.GitHubFileEditor
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
pr_creator:
type: haystack_integrations.components.connectors.github.pr_creator.GitHubPRCreator
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
connections:
- sender: repo_forker.repo
receiver: file_editor.repo
- sender: repo_forker.issue_branch
receiver: file_editor.branch
inputs:
query:
- repo_forker.url
- pr_creator.issue_url
outputs:
result: pr_creator.result
max_runs_per_component: 100
metadata: {}
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
url | str | Full GitHub issue URL (for example, https://github.com/owner/repo/issues/123). |
Outputs
| Parameter | Type | Description |
|---|---|---|
repo | str | Fork path in owner/repo format. |
issue_branch | Optional[str] | Name of the created branch (for example, fix-123) if create_branch is True, otherwise None. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
github_token | Secret | Secret.from_env_var("GITHUB_TOKEN") | GitHub personal access token used for API authentication. |
raise_on_failure | bool | True | If True, raises an exception on errors. If False, returns empty strings. |
wait_for_completion | bool | False | If True, polls until the fork is fully available before returning. |
max_wait_seconds | int | 300 | Maximum number of seconds to wait when wait_for_completion is True. |
poll_interval | int | 2 | Seconds between status checks when waiting for fork completion. |
auto_sync | bool | True | If True, syncs an existing fork with the upstream repository instead of creating a new one. |
create_branch | bool | True | If True, creates a fix-<issue-number> branch in the fork. |
Related Information
Was this page helpful?