AI agents in CI/CD pipelines
Where AI helps in pipelines (reviews, summaries, failure explanations) and the rules that keep it safe.
Good jobs for AI in a pipeline are ones where a person reads the output anyway: reviewing a pull request's diff, summarising changes for release notes, explaining why a build failed. The AI step produces advice, posted as a comment or a job summary.
Pipelines are a tempting target, because they hold secrets and can deploy. So the AI step gets the least: read access to code, permission to comment, no deployment credentials, no approval or merge rights. Use the pull_request trigger so forked pull requests get a read-only token and no secrets.
The diff, the pull request text and commit messages are all untrusted input that may carry prompt injection. Keep the AI step's output out of anything executed, never let it approve its own work, and keep evaluation cases for the reviewer like any other agent.
Cost. Free to practise with a rule-based reviewer in a public repository. Real models cost per token, or use a free rate-limited tier for trials.
Use it when
- a team wants AI reviews or summaries on pull requests.
- you're reviewing a workflow that calls a model.
- build failures need faster triage.
How it works
- Pick advisory jobs
- Reviews, summaries, explanations.
- Least privilege
- contents: read, pull-requests: write.
- Safe triggers
- pull_request, not pull_request_target with PR code.
- No secrets
- Except a scoped model key, never for forks.
- People decide
- AI comments; humans approve and merge.
Options
- Rule-based reviewer
- Free and predictable; catches known patterns.
- Model-based reviewer
- Catches more, costs tokens, needs evaluations.
Example. Kestwick Hotels' pull requests get an AI summary and a list of risky changes as one comment, updated on each push. Required approvals still come from two engineers; the AI can't approve anything.
Don't confuse it with
- AI review comment
- Advice a person weighs.
- Required check
- A gate that blocks merging; keep AI out of this until it's proven.
Words to know
- Advisory step
- A step whose output informs people but blocks nothing.
- pull_request_target
- A trigger that runs with the base repository's rights; risky with untrusted code.
- Job summary
- Markdown a workflow step shows on the run page.
Where to look
- Repository
- .github/workflows
- Pull requests
Practise it
- Add a practice AI reviewer to pull requestsHow-to, Free
- Use AI in pipelines safelyHow-to, Free
- Keep secrets safe in a pipelineHow-to, Free
Read it in the guide, next to the tasks and labs.
Open in DevOps, Hands On