Skip to main content

Configuring automatic code review by Copilot

Learn how to configure Copilot to automatically review pull requests.

Introduction

This article tells you how to set up Revisão de código do Copilot to review pull requests automatically. For an overview of automatic pull request reviews, see About Copilot code review.

The three sections in this article tell you how to configure automatic code review for:

Configuring automatic code review for all pull requests you create

Observação

This is only available if you are on the Copilot Pro or Copilot Pro+ plan.

  1. In the upper-right corner of any page, click your profile picture, then click Your Copilot.

  2. Locate the Automatic Revisão de código do Copilot option and click the dropdown button.

    Screenshot of the "Automatic Revisão de código do Copilot" setting with the dropdown menu displayed.

  3. In the dropdown menu, select Enabled.

Configuring automatic code review for a single repository

  1. Em GitHub, acesse a página principal do repositório.

  2. Abaixo do nome do repositório, clique em Configurações. Caso não consiga ver a guia "Configurações", selecione o menu suspenso , clique em Configurações.

    Captura de tela de um cabeçalho de repositório que mostra as guias. A guia "Configurações" é realçada por um contorno laranja-escuro.

  3. Na barra lateral esquerda, em "Código e automação", clique em Regras e em Conjuntos de regras.

    Captura de tela da barra lateral da página "Configurações" de um repositório. O submenu "Regras" está expandido, e a opção "Conjuntos de regras" está realçada em laranja.

  4. Clique em Novo conjunto de regras.

  5. Clique em Novo conjunto de regras de branch.

  6. Em "Nome do conjunto de regras", digite um nome para o conjunto de regras.

  7. Para ativar o conjunto de regras, em "Status de Imposição", selecione Ativo.

  8. Under "Target branches," click Add target and choose one of the options—for example, Include default branch or Include all branches.

  9. Under "Branch rules," select the Require a pull request before merging checkbox.

    This expands a set of subsidiary options.

  10. Select the Request pull request review from Copilot checkbox.

    Screenshot of the "Request pull request review from Copilot" branch ruleset option.

  11. At the bottom of the page, click Create.

Configuring automatic code review for repositories in an organization

  1. No canto superior direito de GitHub, selecione sua foto de perfil e clique em Your organizations.

  2. Ao lado da organização, clique em Configurações.

  3. Na barra lateral esquerda, na seção "Código, planejamento e automação", clique em Repositório e em Conjuntos de regras.

    Captura de tela da página de configurações de uma organização. Na barra lateral, um link rotulado "Conjuntos de regras" está realçado em laranja.

  4. Clique em Novo conjunto de regras.

  5. Clique em Novo conjunto de regras de branch.

  6. Em "Nome do conjunto de regras", digite um nome para o conjunto de regras.

  7. Para ativar o conjunto de regras, em "Status de Imposição", selecione Ativo.

  8. Under "Target repositories," click Add target and choose either Include by pattern or Exclude by pattern.

  9. In the dialog box that's displayed, type a pattern that will match the names of repositories in your organization—for example, *feature to match all repositories with names that end in feature.

    For information about pattern-matching syntax, see Criar conjuntos de regras para repositórios na sua organização.

  10. In the dialog box, click Add inclusion pattern or Add exclusion pattern.

  11. Repeat the process for any additional patterns you want to add.

    Observação

    You can add multiple targeting criteria to the same ruleset. Exclusion patterns are applied after inclusion patterns. For example, you could include any repositories matching the pattern *cat*, and specifically exclude a repository matching the pattern not-a-cat.

  12. Under "Target branches," click Add target and choose one of the target options.

  13. Under "Branch rules," select the Require a pull request before merging checkbox.

    This expands a set of subsidiary options.

  14. Select the Request pull request review from Copilot checkbox.

  15. At the bottom of the page, click Create.