Example Build Failure

Creating A GitHub Actions Build Failure Agent
Let’s create an Agent that runs every time we get a GitHub Actions build failure alert. Our Agent will extract the workflow and job details from the alert, fetch the failing job logs, analyze the specific error, use Claude Code to automatically fix the issue, and create a pull request with the fix. After installing Unpage, create the agent by running:$EDITOR
. Paste the following Agent definition
into the file:
Description: When the agent should run
Thedescription
of an Agent is used by the Router to
decide which Agent to run for a given input. In this example we want the Agent
to run only when the alert is about GitHub Actions workflow failures on main
branches or releases, not pull request failures.
Prompt: What the agent should do
Theprompt
is where you give the Agent instructions, written in a runbook
format. Make sure any instructions you give are achievable using the tools
you have allowed the Agent to use (see below).
Tools: What the agent is allowed to use
Thetools
section explicitly grants permission to use specific tools. You can
list individual tools, or use wildcards and regex patterns to limit what the
Agent can use.
To see all of the available tools your Unpage installation has access to, run:
shell_get_last_failing_run
shell_fetch_run_logs
shell_noninteractive_claude_code_run
shell_commit_and_open_pull_request
gh
),
Claude Code in Headless Mode,
and standard git commands to interact with GitHub Actions and automate fixes.
Custom shell commands allow you to extend the functionality of Unpage without
having to write a new plugin.
Defining Custom Tools
To add our custom GitHub Actions analysis and automation tools, edit~/.unpage/profiles/default/config.yaml
and add the following:
gh
) and git commands. Make sure you have the GitHub CLI installed and
authenticated (gh auth login
) and that the repository is cloned locally.
See shell commands for more details.
Running Your Agent
With your Agent configured and the custom GitHub Actions automation tools added, we are ready to test it on a real PagerDuty alert.Testing on an existing alert
To test your Agent locally on a specific PagerDuty alert, run:Listening for webhooks
To have your Agent listen for new PagerDuty alerts as they happen, rununpage agent serve
and add the webhook URL to your PagerDuty account:
Example Output
Your Agent will:- Extract the repository name from the alert
- Query GitHub Actions for the most recent failing run ID using
gh run list
- Fetch complete logs from the failing run using
gh run view --log
- Use Claude Code to analyze the root cause and attempt an automated fix
- Create a pull request with the automated fix (if successful) for human review
- Provide detailed explanation of what was changed and why in the PR description
- Stop and wait for human intervention if no automated fix could be applied