Gate AI-generated pull requests in GitHub Actions
When agents open pull requests, the review bottleneck moves to CI: an AI-generated change can look plausible line-by-line and still carry a destructive migration, a weakened policy, or a credential leak.
Mergen’s CI gate runs the same deterministic policy engine your developers already have locally against the changes in the pipeline — flagging high-risk diffs and enforcing a human approval step before merge or deployment. Every build is fully protected on every plan; plan limits are informational only and never weaken a verdict.
What is covered, precisely
- The repo ships a ready-made GitHub Action (action.yml) that POSTs each PR's files and diff to your Mergen server's /ci/gate endpoint and returns a pass/warn/block verdict.
- A block verdict fails the workflow step by default (fail-on-block) and, with status-check enabled, posts a required commit status — branch protection then blocks merge until the PR is fixed or the policy is reviewed.
- PR comments (post-comment input, or MERGEN_PR_COMMENTS=true on the server) post the gate's findings — verdict, risk score, and reasons — directly on the pull request.
- Separately, build-status ingest (POST /ci/generic) correlates CI run outcomes with browser/backend errors by commit SHA for incident triage — this is independent of the policy gate above.
Wire it into a workflow
- uses: actions/checkout@v4
- name: Mergen AEG Gate
uses: <path-or-ref-to-action.yml>
with:
mergen-url: ${{ secrets.MERGEN_URL }}
mergen-secret: ${{ secrets.MERGEN_SECRET }}curl -X POST http://your-mergen-host:3000/ci/generic \
-H 'Content-Type: application/json' \
-d '{"status":"failed","branch":"main","sha":"'$GITHUB_SHA'","url":"'$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID'"}'What gets stopped
PR that adds `terraform destroy` to a deploy jobMigration dropping a column in useWorkflow step that echoes secretsHuman-in-the-loop approvals
A block verdict fails a required commit status, so branch protection stops the merge until a human resolves it — either by fixing the PR or by reviewing the matched policy through the normal override workflow. There is no in-pipeline Slack approval step for this gate; that HITL flow is for local/MCP tool-call holds, not CI.