A Deploy-it-Yourself Cloudflare Worker that automatically fixes failed GitHub Actions workflows using Nvidia NIM AI.
When a GitHub Actions workflow fails, developers usually dig through logs, find the broken file, figure out the fix, and push a new commit.
This Deploy-it-Yourself GitHub App receiver automates the entire process:
- Receives
workflow_runfailure webhooks. - Authenticates as a GitHub App (JWT β token).
- Downloads & extracts workflow failure logs.
- Identifies the broken source files.
- Sends logs + code to Nvidia NIM for a fix.
- Commits the fixed code back to your branch!
- Runtime: Cloudflare Workers (TypeScript)
- AI Model: Nvidia NIM
minimaxai/minimax-m2.5with automatic fallback toz-ai/glm5andmoonshotai/kimi-k2.5. - Security: Web Crypto API for HMAC-SHA256 signature verification and RS256 JWT generation.
- Zero Heavy Dependencies: No LangChain, no databases, no KV storage. Fully stateless.
git clone \
https://github.com/chirag127/github-actions-ai-auto-debugger.git
cd github-actions-ai-auto-debugger
npm install- Go to Settings β Developer settings β GitHub Apps β New GitHub App.
- Name: AI Auto-Debugger (or your choice).
- Webhook URL: Update after deploying.
- Webhook Secret: Generate a random string.
- Permissions:
- Actions: Read-only
- Contents: Read & write
- Subscribe to events: Check
Workflow run. - Click Create GitHub App.
- Note your App ID.
- Click Generate a private key (downloads
a
.pemfile).
On your GitHub App's "Install App" page, install it on the repositories you want the AI to debug.
npx wrangler secret put WEBHOOK_SECRET
npx wrangler secret put GITHUB_APP_ID
npx wrangler secret put GITHUB_PRIVATE_KEY
npx wrangler secret put NVIDIA_API_KEYnpm run deployNote the Worker URL printed in your terminal.
- Go back to your GitHub App settings.
- Set the Webhook URL to your Worker URL.
- Save changes.
Run the full test suite locally:
npm run testRun the end-to-end tests that verify the full webhook β auth β fix β commit flow:
npm run test:e2eUse the included script to send a mock webhook payload to your deployed Worker:
npx tsx scripts/test-e2e.tsThis sends a signed workflow_run failure event.
A 500 about "Failed to get installation token"
means the Worker correctly validated the signature
and attempted GitHub authentication (expected with
a mock installation ID).
Test the Nvidia NIM AI directly with a mock bug:
npx tsx scripts/test-ai.tsCreate a .env file in the project root:
WEBHOOK_SECRET=your_webhook_secret
GITHUB_APP_ID=your_app_id
GITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
...your key here...
-----END RSA PRIVATE KEY-----"
NVIDIA_API_KEY=nvapi-your-key-here
CLOUDFLARE_ACCOUNT_ID=your_account_id
CLOUDFLARE_API_TOKEN=your_api_token
β οΈ NEVER commit.envto version control. It is already in.gitignore.
Run the local dev server:
npm run devLint and format:
npm run lint
npm run lint:fix
npm run formatType check:
npm run typecheck- Infinite Loop Protection: Ignores failures
triggered by bot accounts (
[bot],github-actions,dependabot,renovate). - Context Window Management: Logs truncated to 15,000 characters to fit AI context windows.
- Resiliency: Exponential backoff with jitter for Nvidia API rate limits and server errors.
- Multi-Model Fallback: Automatically tries alternate AI models if the primary one fails.
If the bot doesn't fix a failing workflow, follow these steps to diagnose the issue:
- Go to Settings β Developer settings β GitHub Apps β Your App β Advanced.
- Look at Recent Deliveries.
- Check the Response tab for each delivery.
200= Worker processed successfully.401= Signature mismatch. Verify yourWEBHOOK_SECRETmatches in both GitHub App settings and Cloudflare Worker secrets.500= Worker error. Check the response body for the error message.
npx wrangler tailThis streams real-time logs from the deployed
Worker. Look for β or π₯ error prefixes.
npx wrangler secret listEnsure all 4 secrets are listed:
WEBHOOK_SECRETGITHUB_APP_IDGITHUB_PRIVATE_KEYNVIDIA_API_KEY
Your GitHub App needs:
- Actions: Read-only (to download logs)
- Contents: Read & write (to commit fixes)
- Metadata: Read (automatic)
The GITHUB_PRIVATE_KEY must be the full PEM
including -----BEGIN RSA PRIVATE KEY----- and
-----END RSA PRIVATE KEY----- lines.
If stored with \n escapes, ensure they are
actual newlines when set via wrangler secret.
Test your API key directly:
curl -s https://integrate.api.nvidia.com/v1/models \
-H "Authorization: Bearer YOUR_NVIDIA_API_KEY" \
| head -c 200If you get a 401, your key is invalid or
expired. Get a new one from
build.nvidia.com.
npm run devThen send a test webhook from another terminal:
npx tsx scripts/test-e2e.ts(Update WORKER_URL in the script to
http://localhost:8787 for local testing.)
If the GitHub Actions CI fails:
- Check the Actions tab on GitHub.
- Click the failed run.
- Common failures:
- Lint errors: Run
npm run lint:fix. - Type errors: Run
npm run typecheck. - Test failures: Run
npm run test. - Deploy fails: Ensure
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDare set as GitHub repository secrets.
- Lint errors: Run
| Error | Cause | Fix |
|---|---|---|
Missing signature |
No X-Hub-Signature-256 header |
Ensure webhook secret is configured in GitHub App |
Invalid signature |
Secret mismatch | Re-set WEBHOOK_SECRET in both GitHub and Cloudflare |
Missing installation ID |
App not installed on repo | Install the GitHub App on the target repo |
Failed to get installation token |
Bad JWT or key | Re-upload the private key via wrangler secret put |
Nvidia API error (401) |
Invalid API key | Get a new key from build.nvidia.com |
No error files identified |
Logs didn't contain recognizable file paths | The AI couldn't parse the error β check log format |
MIT License