Skip to content

jamacku/review-buddy

Β 
Β 

Repository files navigation

Review Buddy

GitHub Marketplace Lint Code Base Unit Tests CodeQL Check dist/

codecov

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.

Features

  • 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

Usage

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_run trigger, downloads artifact, and runs review-buddy GitHub 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 }}

Real-life examples

  • source-git-automation - Used as part of the source-git automation pipeline alongside other validation actions

Configuration options

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>

# ...

pr-metadata

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

token

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

gemini-api-key

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

model

Gemini model identifier to use for analysis. See available models for a list of supported models.

  • default value: gemini-2.5-flash
  • requirements: optional

review-event

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

Outputs

status

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.

Limitations

  • 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

About

πŸ‘€ GitHub Action that analyzes code changes and ci failures and provide feedback

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%