File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Gerar descrição do PR com IA
2+
3+ on :
4+ pull_request :
5+ types : [opened, reopened]
6+
7+ permissions :
8+ contents : read
9+ pull-requests : write
10+ models : read
11+
12+ jobs :
13+ describe :
14+ # Só gera a descrição se o autor não tiver escrito nada.
15+ if : github.event.pull_request.body == '' || github.event.pull_request.body == null
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : Checkout
19+ uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 0
22+
23+ - name : Gerar diff do PR
24+ run : |
25+ git fetch origin "${{ github.event.pull_request.base.ref }}" --depth=1
26+ git diff "origin/${{ github.event.pull_request.base.ref }}...HEAD" \
27+ -- . ':(exclude)package-lock.json' ':(exclude)*.lock' \
28+ > pr.diff
29+ # Evita estourar o limite de tokens do modelo em PRs muito grandes.
30+ head -c 20000 pr.diff > pr.diff.trunc && mv pr.diff.trunc pr.diff
31+
32+ - name : Gerar descrição com GitHub Models
33+ id : inference
34+ uses : actions/ai-inference@v1
35+ with :
36+ model : openai/gpt-4o-mini
37+ system-prompt : |
38+ Você escreve descrições de Pull Request em português do Brasil, em Markdown,
39+ com base apenas no diff fornecido. Use as seções "## Resumo" e "## Mudanças"
40+ (lista de bullets). Seja direto, sem inventar contexto que não esteja no diff.
41+ prompt-file : pr.diff
42+ response-file : description.md
43+
44+ - name : Atualizar descrição do PR
45+ env :
46+ GH_TOKEN : ${{ github.token }}
47+ run : gh pr edit "${{ github.event.pull_request.number }}" --body-file description.md
You can’t perform that action at this time.
0 commit comments