Back to Autogpt

GitHub Pull Requests

docs/integrations/block-integrations/github/pull_requests.md

0.6.4410.0 KB
Original Source

GitHub Pull Requests

<!-- MANUAL: file_description -->

Blocks for managing GitHub pull requests including creating, reading, listing PRs, and assigning or unassigning reviewers.

<!-- END MANUAL -->

Github Assign PR Reviewer

What it is

This block assigns a reviewer to a specified GitHub pull request.

How it works

<!-- MANUAL: how_it_works -->

This block requests a code review from a specific user on a GitHub pull request. It uses the GitHub API to add the specified username to the list of requested reviewers, triggering a notification to that user.

The reviewer must have access to the repository. Organization members can typically be assigned as reviewers on any repository they have at least read access to.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
pr_urlURL of the GitHub pull requeststrYes
reviewerUsername of the reviewer to assignstrYes

Outputs

OutputDescriptionType
errorError message if the reviewer assignment failedstr
statusStatus of the reviewer assignment operationstr

Possible use case

<!-- MANUAL: use_case -->

Automated Code Review Assignment: Automatically assign reviewers based on the files changed or the PR author.

Round-Robin Reviews: Distribute code review load evenly across team members.

Expertise-Based Routing: Assign reviewers who are experts in the specific area of code being modified.

<!-- END MANUAL -->

Github List PR Reviewers

What it is

This block lists all reviewers for a specified GitHub pull request.

How it works

<!-- MANUAL: how_it_works -->

This block retrieves the list of requested reviewers for a GitHub pull request. It queries the GitHub API to fetch all users who have been requested to review the PR, returning their usernames and profile URLs.

This includes both pending review requests and users who have already submitted reviews.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
pr_urlURL of the GitHub pull requeststrYes

Outputs

OutputDescriptionType
errorError message if listing reviewers failedstr
reviewerReviewers with their username and profile URLReviewer
reviewersList of reviewers with their username and profile URLList[ReviewerItem]

Possible use case

<!-- MANUAL: use_case -->

Review Status Monitoring: Check which reviewers have been assigned to a PR and send reminders to those who haven't responded.

Workflow Validation: Verify that required reviewers have been assigned before a PR can be merged.

Team Dashboard: Display reviewer assignments across multiple PRs for team visibility.

<!-- END MANUAL -->

Github List Pull Requests

What it is

This block lists all pull requests for a specified GitHub repository.

How it works

<!-- MANUAL: how_it_works -->

This block fetches all open pull requests from a GitHub repository. It queries the GitHub API and returns a list of PRs with their titles and URLs, outputting both individual PRs and a complete list.

The block returns open pull requests by default, allowing you to monitor pending code changes in a repository.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
repo_urlURL of the GitHub repositorystrYes

Outputs

OutputDescriptionType
errorError message if listing pull requests failedstr
pull_requestPRs with their title and URLPull Request
pull_requestsList of pull requests with their title and URLList[PRItem]

Possible use case

<!-- MANUAL: use_case -->

PR Dashboard: Create a dashboard showing all open pull requests across your repositories.

Merge Queue Monitoring: Track pending PRs to prioritize code reviews and identify bottlenecks.

Stale PR Detection: List PRs to identify those that have been open too long and need attention.

<!-- END MANUAL -->

Github Make Pull Request

What it is

This block creates a new pull request on a specified GitHub repository.

How it works

<!-- MANUAL: how_it_works -->

This block creates a new pull request on a GitHub repository. It uses the GitHub API to submit a PR from your source branch (head) to the target branch (base), with the specified title and description.

For cross-repository PRs, format the head branch as "username:branch". The branches must exist and have divergent commits for the PR to be created successfully.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
repo_urlURL of the GitHub repositorystrYes
titleTitle of the pull requeststrYes
bodyBody of the pull requeststrYes
headThe name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.strYes
baseThe name of the branch you want the changes pulled into.strYes

Outputs

OutputDescriptionType
errorError message if the pull request creation failedstr
numberNumber of the created pull requestint
urlURL of the created pull requeststr

Possible use case

<!-- MANUAL: use_case -->

Automated Releases: Create PRs automatically when a release branch is ready to merge to main.

Dependency Updates: Programmatically create PRs for dependency updates after testing passes.

Feature Flags: Automatically create PRs to enable feature flags in configuration files.

<!-- END MANUAL -->

Github Merge Pull Request

What it is

This block merges a pull request using merge, squash, or rebase.

How it works

<!-- MANUAL: how_it_works -->

This block merges a pull request using the GitHub Merge API. It supports three merge methods: regular merge commit, squash merge (combines all commits into one), and rebase merge (replays commits on top of the base branch).

You can optionally provide a custom commit title and message for merge and squash methods. The block returns the merge commit SHA and confirmation of success.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
pr_urlURL of the GitHub pull requeststrYes
merge_methodMerge method to use: merge, squash, or rebase"merge" | "squash" | "rebase"No
commit_titleTitle for the merge commit (optional, used for merge and squash)strNo
commit_messageMessage for the merge commit (optional, used for merge and squash)strNo

Outputs

OutputDescriptionType
errorError message if the merge failedstr
shaSHA of the merge commitstr
mergedWhether the PR was mergedbool
messageMerge status messagestr

Possible use case

<!-- MANUAL: use_case -->

CI/CD Pipeline: Automatically merge PRs after all checks pass and required approvals are received.

Release Automation: Merge release branches into main using squash for clean commit history.

Dependency Updates: Auto-merge bot-created PRs for minor dependency updates after tests pass.

<!-- END MANUAL -->

Github Read Pull Request

What it is

This block reads the body, title, user, and changes of a specified GitHub pull request.

How it works

<!-- MANUAL: how_it_works -->

This block reads the details of a GitHub pull request including its title, description, author, and optionally the code diff. It fetches this information via the GitHub API using your credentials.

When include_pr_changes is enabled, the block also retrieves the full diff of all changes in the PR, which can be useful for code review automation or analysis.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
pr_urlURL of the GitHub pull requeststrYes
include_pr_changesWhether to include the changes made in the pull requestboolNo

Outputs

OutputDescriptionType
errorError message if reading the pull request failedstr
titleTitle of the pull requeststr
bodyBody of the pull requeststr
authorUser who created the pull requeststr
changesChanges made in the pull requeststr

Possible use case

<!-- MANUAL: use_case -->

Automated Code Review: Read PR content and changes to perform automated code analysis or send to AI for review.

Changelog Generation: Extract PR titles and descriptions to automatically compile release notes.

PR Summarization: Read PR details to generate summaries for stakeholder updates.

<!-- END MANUAL -->

Github Unassign PR Reviewer

What it is

This block unassigns a reviewer from a specified GitHub pull request.

How it works

<!-- MANUAL: how_it_works -->

This block removes a reviewer from a GitHub pull request's review request list. It uses the GitHub API to remove the specified user from pending reviewers, which stops further review notifications to that user.

This is useful for reassigning reviews or removing reviewers who are unavailable.

<!-- END MANUAL -->

Inputs

InputDescriptionTypeRequired
pr_urlURL of the GitHub pull requeststrYes
reviewerUsername of the reviewer to unassignstrYes

Outputs

OutputDescriptionType
errorError message if the reviewer unassignment failedstr
statusStatus of the reviewer unassignment operationstr

Possible use case

<!-- MANUAL: use_case -->

Reviewer Reassignment: Remove unavailable reviewers and replace them with available team members.

Load Balancing: Unassign reviewers who have too many pending reviews.

Vacation Coverage: Automatically remove reviewers who are out of office.

<!-- END MANUAL -->