Branch Actions Detective¶
Analyze failed branch CI runs and create or update a tracking issue.
Workflow source: gh-aw-branch-actions-detective.md
How it works¶
Triggered automatically when a CI workflow fails on a protected branch (e.g. main) without an associated PR. Reads the failed job logs, identifies the root cause, and creates an issue with findings and recommended fixes. Repeated failures for the same root cause are deduplicated — existing issues are left open and no duplicate is filed.
Quick Install¶
mkdir -p .github/workflows && curl -sL \
https://raw.githubusercontent.com/elastic/ai-github-actions/v0/gh-agent-workflows/branch-actions-detective/example.yml \
-o .github/workflows/branch-actions-detective.yml
Trigger¶
| Event | Types | Condition |
|---|---|---|
workflow_run |
completed |
CI workflow failed on the default branch with no associated 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¶
create-issue— file a tracking issue for the CI failure (max 1, auto-closes older issues)
Example Workflow¶
name: Branch Actions Detective
on:
workflow_run:
workflows: ["Internal: CI", "CI", "Build", "Test"]
types: [completed]
permissions:
actions: read
contents: read
issues: write
jobs:
run:
if: >-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.head_branch == github.event.repository.default_branch &&
toJSON(github.event.workflow_run.pull_requests) == '[]'
uses: elastic/ai-github-actions/.github/workflows/gh-aw-branch-actions-detective.lock.yml@v0
secrets:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}