Skip to main content

Administración de conjuntos de reglas de un repositorio

Puede editar, supervisar y eliminar conjuntos de reglas existentes en un repositorio para modificar cómo las personas pueden interactuar con ramas y etiquetas específicas.

¿Quién puede utilizar esta característica?

Cualquier persona con acceso de lectura a un repositorio puede ver los conjuntos de reglas del repositorio. Las personas con acceso de administrador a un repositorio o un rol personalizado con el permiso "editar reglas de repositorio", pueden crear, editar y eliminar conjuntos de reglas para un repositorio.

Los conjuntos de reglas están disponibles en los repositorios públicos con GitHub Free y GitHub Free para organizaciones, y en los repositorios públicos y privados con GitHub Pro, GitHub Team y GitHub Enterprise Cloud. Para más información, consulta Planes de GitHub.

Los conjuntos de reglas de inserción están disponibles para el plan GitHub Team en repositorios internos y privados, y bifurcaciones de repositorios que tienen habilitados conjuntos de reglas de inserción.

After creating a ruleset, you can still make changes to it. For example, you can add rules to better protect your branches or tags, or you can temporarily disable a ruleset to troubleshoot any unintended effects on the contributor experience for your repository.

You can use the REST and GraphQL APIs to manage rulesets. For more information, see REST API endpoints for rules and Mutations.

Viewing rulesets for a repository

On the "Rulesets" page, anyone with read access to the repository can view the active rulesets targeting a certain branch, tag, or push restriction.

For push rulesets for forked repositories, the "Rulesets" page will indicate that the ruleset is managed by the source repository where the rule is applied.

  1. On GitHub, navigate to the main page of the repository.

  2. From the file tree view on the left, select the branch dropdown menu, then click View all branches. You can also find the branch dropdown menu at the top of the integrated file editor.

    Screenshot of the file tree view for a repository. A dropdown menu for branches is expanded and outlined in dark orange.

  3. To the left of the branch name, click .

    Sugerencia

    Only branches that have a ruleset have a icon adjacent to their name.

  4. Optionally, to filter the results click the tabs or use the "Search branches" search bar.

  5. Click the name of the ruleset you want to view.

You can also view active ruselets:

  • By adding the /rules slug to the repository's URL. For example, to view the rules of the open source documentation repository at GitHub, you would go to https://github.com/github/docs/rules.

  • In the merge box if there are rules blocking the merging of a pull request.

Editing a ruleset

You can edit a ruleset to change parts of the ruleset, such as the name, bypass permissions, or rules. You can also edit a ruleset to change its status, such as if you want to enable or temporarily disable a ruleset.

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code and automation," click Rules, then click Rulesets.

    Screenshot of the sidebar of the "Settings" page for a repository. The "Rules" sub-menu is expanded, and the "Rulesets" option is outlined in orange.

  4. On the "Rulesets" page, click the name of the ruleset you want to edit.

  5. Change the ruleset as required. For information on the available rules, see Available rules for rulesets.

  6. At the bottom of the page, click Save changes.

Deleting a ruleset

Sugerencia

If you want to temporarily disable a ruleset but do not want to delete it, you can set the ruleset's status to "Disabled." For more information, see Editing a ruleset.

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code and automation," click Rules, then click Rulesets.

    Screenshot of the sidebar of the "Settings" page for a repository. The "Rules" sub-menu is expanded, and the "Rulesets" option is outlined in orange.

  4. Click the name of the ruleset you want to delete.

  5. To the right of the ruleset's name, select , then click Delete ruleset.

    Screenshot of the page for editing a ruleset. Below a button labeled with three dots, an option labeled "Delete ruleset" is outlined in orange.

Importing a ruleset

You can import an existing ruleset using a JSON file. This can be useful if you want to apply the same ruleset to multiple repositories or organizations.

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code and automation," click Rules, then click Rulesets.

    Screenshot of the sidebar of the "Settings" page for a repository. The "Rules" sub-menu is expanded, and the "Rulesets" option is outlined in orange.

  4. Select the New ruleset dropdown, then click Import a ruleset.

    Screenshot of the page for repository rulesets. The "New ruleset" dropdown menu is expanded and the "Import a ruleset" option is outlined in orange.

  5. Open the exported JSON file.

  6. Review the imported ruleset and click Create.

Viewing insights for rulesets

You can view insights for rulesets to see how rulesets are affecting a repository. On the "Rule Insights" page, you will see a timeline of the following user actions. You can use filters to find what you're looking for.

  • Actions that have been checked against one or more rulesets and passed.
  • Actions that have been checked against one or more rulesets and failed.
  • Actions where someone has bypassed one or more rulesets.

If a ruleset is running in "Evaluate" mode, you can see actions that would have passed or failed if the ruleset had been active.

Additonally these insights are availible via the rule suites REST API.

Screenshot of the "Rule Insights" page. Three actions are listed marked: "Pass," "Bypass," and "Fail". The failed action has with an "evaluate" label.

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code and automation," click Rules, then click Insights.

    Screenshot of the sidebar of the "Settings" page for a repository. The "Rules" sub-menu is expanded, and the "Insights" option is outlined in orange.

  4. On the "Rule Insights" page, use the dropdown menus at the top of the page to filter the actions by ruleset, branch, actor, and time period.

  5. To see which specific rules failed or required a bypass, click , then expand the name of the ruleset.

    Screenshot of the "Rule Insights" page. To the right of an event labeled "not-allowed," an icon of three horizontal dots is outlined in orange.