Skip to content

PR CI Detective

Analyze failed PR checks and report findings (read-only).

How it works

Triggered automatically when a CI workflow fails on a PR. Reads the failed job logs, identifies the root cause, and posts a comment with findings and recommended fixes. Read-only — never pushes changes.

Quick Install

mkdir -p .github/workflows && curl -sL \
  https://raw.githubusercontent.com/elastic/ai-github-actions/v0/gh-agent-workflows/pr-ci-detective/example.yml \
  -o .github/workflows/pr-ci-detective.yml

Trigger

Event Types Condition
workflow_run completed CI workflow failed and the run is associated with a PR

Inputs

Input Description Required Default
additional-instructions Repo-specific instructions appended to the agent prompt No ""
setup-commands Shell commands run before the agent starts No ""
allowed-bot-users Allowlisted bot actor usernames (comma-separated) No github-actions[bot]

Safe Outputs

  • add-comment — post a comment explaining the failure (max 3)

Example Workflow

name: PR CI Detective
on:
  workflow_run:
    workflows: ["CI", "Build", "Test"]
    types: [completed]

permissions:
  actions: read
  contents: read
  discussions: write
  issues: write
  pull-requests: write  # required by gh-aw compiler for add-comment (github/gh-aw#16673)

jobs:
  run:
    if: >-
      github.event.workflow_run.conclusion == 'failure' &&
      toJSON(github.event.workflow_run.pull_requests) != '[]'
    uses: elastic/ai-github-actions/.github/workflows/gh-aw-pr-ci-detective.lock.yml@v0
    secrets:
      COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}