1
Armazene sua chave da API do Devin no GitHub
The workflow calls Devin’s v3 API to create sessions programmatically. Create a service user and store its token as a GitHub Actions secret:
- Go to app.devin.ai > Settings > Devin API > Service users and create a service user with a role that includes the Use Devin sessions (
UseDevinSessions) permission — creating sessions requires this permission, andManageOrgSessionsalone does not grant it - Copy the API token shown after creation — it’s only displayed once
- In your GitHub repo, navigate to Settings > Secrets and variables > Actions
- Add two secrets:
DEVIN_API_KEY(the token) andDEVIN_ORG_ID(your organization ID, shown at the top of the Settings > Devin API page)
2
Adicione o arquivo de workflow
Create Substitua
.github/workflows/devin-ci-fix.yml. This workflow fires whenever your existing CI workflow completes with a failure, extracts the failing job names, and calls the Devin API to start a fix session:"CI" no array workflows pelo name: exato do seu arquivo de workflow de CI existente (por exemplo, "Tests", "Build & Test").Use o campo tags no corpo da requisição (por exemplo, "tags": ["ci-fix", "pr-312"]) para rastrear quais falhas de CI já acionaram sessões e evitar duplicatas.3
O que acontece quando o CI falha
When a PR’s CI run fails, the Action extracts failure details and passes them to Devin as a session prompt. Here’s a typical auto-fix flow:
- Reads the CI logs — Devin opens the run URL and parses the error output, stack traces, and test results from the failing jobs
- Traces the error to code — Locates the relevant file and line on the PR branch (e.g.,
UserList.tsx:34) and reads the surrounding code and recent diff - Pushes a fix — Commits a targeted change directly to the PR branch, which re-triggers CI automatically
- Comments on the PR — Posts a summary explaining the root cause and what was changed
4
Direcione para as falhas certas
Nem toda falha em CI se beneficia de uma correção automática — timeouts de infraestrutura e problemas de build do Docker não serão resolvidos por uma alteração de código. Adicione uma condição para que apenas falhas de jobs relevantes acionem o Devin:Devin faz push de um commit de correção, mas o PR ainda requer revisão humana antes de ser mesclado. Trate correções automáticas como um ponto de partida para o desenvolvedor, não como um substituto para a revisão de código. Se Devin não conseguir resolver a falha, ele comenta no PR explicando o que encontrou, para que um engenheiro possa continuar a partir daí.

