Skip to main content

GitHubPRCreator

Create pull requests from a fork back to the original repository.

Basic Information

  • Type: haystack_integrations.components.connectors.github.pr_creator.GitHubPRCreator
  • Components it can connect with:
    • Input: Receives PR details (title, body, branch) as input.
    • GitHubRepoForker: Works alongside to create fork and branch before PR.
    • GitHubFileEditor: Works alongside to make changes before creating PR.

Inputs

ParameterTypeDefaultDescription
issue_urlstrURL of the GitHub issue to link the PR to.
titlestrTitle of the pull request.
branchstrName of the branch in your fork where changes are implemented.
basestrName of the branch in the original repo you want to merge into.
bodystrAdditional content for the pull request description.
draftboolFalseWhether to create a draft pull request.

Outputs

ParameterTypeDefaultDescription
resultstrOperation result with PR URL or error message.

Overview

GitHubPRCreator creates pull requests from a fork back to the original repository. It uses the authenticated user's fork to create the PR and links it to an existing issue.

This component is useful for building automated pipelines that submit code changes as pull requests, such as automated bug fix systems or code improvement bots.

Authorization

To use this component, you must create a secret with your GitHub personal access token with write access to the repository you want to create a pull request in. Type GITHUB_TOKEN as the secret key. For detailed instructions on creating secrets, see Create Secrets.

Usage Example

This pipeline uses GitHubPRCreator to create a pull request after making changes:

components:
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
wait_for_completion: true
max_wait_seconds: 300
poll_interval: 2
auto_sync: true
create_branch: true

GitHubFileEditor:
type: haystack_integrations.components.connectors.github.file_editor.GitHubFileEditor
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
repo:
branch:
raise_on_failure: true

GitHubPRCreator:
type: haystack_integrations.components.connectors.github.pr_creator.GitHubPRCreator
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true

connections:
- sender: GitHubRepoForker.repo
receiver: GitHubFileEditor.repo
- sender: GitHubRepoForker.issue_branch
receiver: GitHubFileEditor.branch
- sender: GitHubRepoForker.issue_branch
receiver: GitHubPRCreator.branch

inputs:
issue_url:
- GitHubRepoForker.url
- GitHubPRCreator.issue_url
title:
- GitHubPRCreator.title
base:
- GitHubPRCreator.base
body:
- GitHubPRCreator.body
draft:
- GitHubPRCreator.draft
command:
- GitHubFileEditor.command
payload:
- GitHubFileEditor.payload

outputs:
result: GitHubPRCreator.result

max_runs_per_component: 100

metadata: {}

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
github_tokenSecretSecret.from_env_var('GITHUB_TOKEN')GitHub personal access token for authentication (from the fork owner).
raise_on_failureboolTrueIf True, raises exceptions on API errors.

Run Method Parameters

These are the parameters you can configure for the run() method. You can pass these parameters at query time through the API, in Playground, or when running a job.

ParameterTypeDefaultDescription
issue_urlstrURL of the GitHub issue to link the PR to.
titlestrTitle of the pull request.
branchstrName of the branch in your fork where changes are implemented.
basestrName of the branch in the original repo you want to merge into.
bodystrAdditional content for the pull request description.
draftboolFalseWhether to create a draft pull request.