Review Buddy is a GitHub Action that analyzes CI workflow failures alongside Pull Request code changes using Google Gemini. It acts as an AI-powered second reviewer, posting inline review comments that identify which code changes likely caused the CI failures and suggesting fixes.
- Analyze failed CI job logs in the context of Pull Request code changes
- Post inline review comments on the specific lines that caused failures
- Suggest fixes using GitHub's suggestion syntax for one-click apply
- Detect infrastructure flakes and distinguish them from code-related failures
- Configurable Gemini model and review event type
To set up Review Buddy, we need two files:
- Workflow that captures Pull Request metadata (number and commit metadata) and uploads this data as an artifact
- Workflow that runs on
workflow_runtrigger, downloads artifact, and runsreview-buddyGitHub Action
Note
Setup is complicated due to GitHub permissions on GITHUB_TOKEN. When used in workflow executed from fork it has read-only permissions. By using the workflow_run trigger we are able to safely overcome this limitation and it allows us to read workflow logs and post review comments on Pull Requests.
name: Gather Pull Request Metadata
on:
pull_request:
types: [ opened, reopened, synchronize ]
branches: [ main ]
permissions:
contents: read
jobs:
gather-metadata:
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v4
- id: Metadata
name: Gather Pull Request Metadata
uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
- name: Upload artifact with gathered metadata
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: ${{ steps.Metadata.outputs.metadata-file }}name: Review Buddy
on:
workflow_run:
workflows: [ Gather Pull Request Metadata ]
types:
- completed
permissions:
contents: read
jobs:
download-metadata:
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-latest
outputs:
pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }}
steps:
- id: Artifact
name: Download Artifact
uses: redhat-plumbers-in-action/download-artifact@v1
with:
name: pr-metadata
review-buddy:
needs: [ download-metadata ]
runs-on: ubuntu-latest
permissions:
# required for reading workflow logs
actions: read
# required for posting review comments
pull-requests: write
steps:
- name: Review Buddy
uses: redhat-plumbers-in-action/review-buddy@v1
with:
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
gemini-api-key: ${{ secrets.GEMINI_API_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}- source-git-automation - Used as part of the source-git automation pipeline alongside other validation actions
Action currently accepts the following options:
# ...
- uses: redhat-plumbers-in-action/review-buddy@v1
with:
pr-metadata: <pr-metadata.json>
token: <GitHub token or PAT>
gemini-api-key: <Gemini API key>
model: <Gemini model identifier>
review-event: <COMMENT or REQUEST_CHANGES>
# ...Stringified JSON Pull Request metadata provided by GitHub Action redhat-plumbers-in-action/gather-pull-request-metadata.
Pull Request metadata has the following format: metadata format
- default value:
undefined - requirements:
required
GitHub token or PAT is used for reading workflow logs and posting review comments on Pull Request.
# required permissions
permissions:
actions: read
pull-requests: write- default value:
undefined - requirements:
required - recomended value:
secrets.GITHUB_TOKEN
Google Gemini API key used for AI-powered analysis of CI failures. You can obtain an API key from Google AI Studio.
- default value:
undefined - requirements:
required - recomended value:
secrets.GEMINI_API_KEY
Gemini model identifier to use for analysis. See available models for a list of supported models.
- default value:
gemini-2.5-flash - requirements:
optional
The review event type to use when posting the review. Use COMMENT for non-blocking reviews or REQUEST_CHANGES to block merging until the issues are resolved.
- default value:
COMMENT - requirements:
optional
Markdown-formatted status message summarizing the AI review results. Designed for use with redhat-plumbers-in-action/issue-commentator to post a consolidated status comment on the Pull Request.
- Log analysis quality depends on the Gemini model used and the clarity of CI error output
- Very large diffs or logs may be truncated to fit within model context limits
- AI-generated review comments may occasionally suggest incorrect fixes; always verify suggestions before applying
- The action requires a Google Gemini API key, which may incur usage costs depending on the model and volume