Skip to main content

Configuring automatic code review by Copilot

Learn how to configure Copilot to automatically review pull requests in a repository.

About automatic code review

By default, Copilot will only review a pull request when it is assigned to the pull request in the same way you would assign a human reviewer. However, repository owners can configure Copilot to automatically review all pull requests in the repository. Organization owners can configure Copilot to automatically review all pull requests in some or all of the repositories in the organization.

Triggering an automatic pull request review

After you configure automatic code review, Copilot will review pull requests in the following situations:

  • When a pull request is created as an "Open" pull request.

    A review is not triggered if the pull request is created as a "Draft" pull request.

  • The first time a "Draft" pull request is switched to "Open".

Note

Copilot only automatically reviews a pull request once. If you make changes to the pull request after it has been automatically reviewed and you want Copilot to re-review the pull request, you must request this manually. To do this, click the button next to Copilot's name in the Reviewers menu.

Configuring automatic code review for a single repository

  1. En GitHub, navegue hasta la página principal del repositorio.

  2. En el nombre del repositorio, haz clic en Configuración. Si no puedes ver la pestaña "Configuración", selecciona el menú desplegable y, a continuación, haz clic en Configuración.

    Captura de pantalla de un encabezado de repositorio en el que se muestran las pestañas. La pestaña "Configuración" está resaltada con un contorno naranja oscuro.

  3. En la barra lateral izquierda, en "Código y automatización", haz clic en Reglas y, a continuación, haz clic en Conjuntos de reglas.

    Captura de pantalla de la barra lateral de la página "Configuración" de un repositorio. El submenú "Reglas" se expande y la opción "Conjuntos de reglas" tiene un contorno naranja.

  4. Click New ruleset.

  5. Click New branch ruleset.

  6. Under "Ruleset name," type a name for the ruleset.

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

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

    This expands a set of subsidiary options.

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

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

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

Configuring automatic code review for repositories in an organization

  1. En la esquina superior derecha de GitHub, seleccione la foto del perfil y haga clic en Sus organizaciones.

  2. Junto a la organización, haga clic en Settings.

  3. En la barra lateral izquierda, en la sección "Código, planeamiento y automatización", haz clic en Repositorio y, luego, haz clic en Conjuntos de reglas.

    Captura de pantalla de la página de configuración de una organización. En la barra lateral, aparece un vínculo etiquetado como "Conjuntos de reglas" con un contorno naranja.

  4. Click New ruleset.

  5. Click New branch ruleset.

  6. Under "Ruleset name," type a name for the ruleset.

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

  8. 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 Creación de conjuntos de reglas para repositorios de la organización.

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

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

    Note

    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.

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

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

    This expands a set of subsidiary options.

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

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