From fd204f434b0b23417bece826fb46fa8c5b2d1ae2 Mon Sep 17 00:00:00 2001 From: Samuelson Date: Fri, 24 Jul 2026 21:52:56 -0300 Subject: [PATCH] =?UTF-8?q?ci:=20gerar=20descri=C3=A7=C3=A3o=20do=20PR=20a?= =?UTF-8?q?utomaticamente=20com=20GitHub=20Models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adiciona workflow que roda ao abrir um PR sem descrição: extrai o diff contra a branch base e usa actions/ai-inference (GitHub Models) para preencher a descrição via gh pr edit. Não requer secrets extras, usa o GITHUB_TOKEN do próprio workflow. --- .github/workflows/pr-description.yml | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/pr-description.yml diff --git a/.github/workflows/pr-description.yml b/.github/workflows/pr-description.yml new file mode 100644 index 0000000..259b529 --- /dev/null +++ b/.github/workflows/pr-description.yml @@ -0,0 +1,47 @@ +name: Gerar descrição do PR com IA + +on: + pull_request: + types: [opened, reopened] + +permissions: + contents: read + pull-requests: write + models: read + +jobs: + describe: + # Só gera a descrição se o autor não tiver escrito nada. + if: github.event.pull_request.body == '' || github.event.pull_request.body == null + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Gerar diff do PR + run: | + git fetch origin "${{ github.event.pull_request.base.ref }}" --depth=1 + git diff "origin/${{ github.event.pull_request.base.ref }}...HEAD" \ + -- . ':(exclude)package-lock.json' ':(exclude)*.lock' \ + > pr.diff + # Evita estourar o limite de tokens do modelo em PRs muito grandes. + head -c 20000 pr.diff > pr.diff.trunc && mv pr.diff.trunc pr.diff + + - name: Gerar descrição com GitHub Models + id: inference + uses: actions/ai-inference@v1 + with: + model: openai/gpt-4o-mini + system-prompt: | + Você escreve descrições de Pull Request em português do Brasil, em Markdown, + com base apenas no diff fornecido. Use as seções "## Resumo" e "## Mudanças" + (lista de bullets). Seja direto, sem inventar contexto que não esteja no diff. + prompt-file: pr.diff + response-file: description.md + + - name: Atualizar descrição do PR + env: + GH_TOKEN: ${{ github.token }} + run: gh pr edit "${{ github.event.pull_request.number }}" --body-file description.md