Fix CI failures
This workflow uses the pre-configured mcp_github_checks_server MCP server to analyze failed GitHub Actions checks.
The prompt contains instructions for Junie CLI to analyze the failed CI runs, identify root causes, and propose fixes.
# .github/workflows/fix-ci.yml
name: Fix CI Failures
on:
workflow_run:
workflows: ["CI"] # Replace with your CI workflow name
types: [completed]
jobs:
analyze-failure:
if: github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
checks: read # Permission needed for CI failure analysis with MCP servers
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 1
- uses: JetBrains/junie-github-action@v0
with:
junie_api_key: ${{ secrets.JUNIE_API_KEY }}
allowed_mcp_servers: "mcp_github_checks_server"
use_single_comment: true
prompt: |
CI workflow "${{ github.event.workflow_run.name }}" failed. Diagnose and fix if possible.
**Analysis:**
1. Use `get_pr_failed_checks_info` MCP tool to fetch error logs
2. Identify failing step and error message
3. Determine root cause (test/build error, timeout, flaky test)
4. Check recent commits that might have caused it
**Provide diagnosis:**
## CI Failure Analysis
**Failed step:** [name]
**Error:** [message]
**Root cause:** [1-2 sentences]
## Proposed Fix
[Description]
## Files to Change
- `path/file`: [what needs to change]
Only provide analysis without modifying files.
Permission configuration
Note that, besides the required permissions, the workflows that perform CI failure analysis require additional read permissions to check runs and fetch logs.
permissions:
contents: write # Required to create branches, make commits, and push changes
pull-requests: write # Required to create PRs, add comments to PRs, and update PR status
issues: write # Required to add comments to issues and update issue metadata
checks: read # Optional: needed for CI failure analysis with MCP servers
actions: read # Optional: needed for CI failure analysis with MCP servers (to fetch logs)
26 January 2026