我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

将标签与自托管运行器一起使用

您可以使用标签以基于其特性来组织自托管运行器。

本文内容

Did this doc help you?

有关如何使用标签将作业路由到特定类型的自托管运行器的信息,请参阅“在工作流程中使用自托管的运行器”。

自托管运行器可位于 GitHub 的组织或仓库设置中。 要管理自托管运行器,您必须拥有以下权限,具体取决于添加自托管运行器的位置:

  • User repository: You must be the repository owner.

  • Organization: You must be an organization owner.

  • Organization repository: You must be an organization owner, or have admin access to the repository.

  • Enterprise account: You must be an enterprise owner.

创建自定义标签

  1. Navigate to where your self-hosted runner is registered:

    • In an organization or repository: navigate to the main page and click Settings.
    • If using an enterprise account: navigate to your enterprise account by visiting https://github.com/enterprises/ENTERPRISE-NAME, replacing ENTERPRISE-NAME with your enterprise account's name. In the enterprise sidebar, Policies.
  2. Navigate to the GitHub Actions settings:

    • In an organization or repository: click Actions in the left sidebar.

      操作设置

    • If using an enterprise account: click Actions under " Policies".

  3. Locate the list of runners under "Self-hosted runners".

  4. If your runner is in a group, locate the runner group and click to view the list of runners.

    List runner group

  5. Locate the runner you want to update, and click to view the label selection menu. 此菜单显示您的自托管运行器可用的所有自定义标签。 已分配给自托管运行器的标签旁边有

    更改运行器标签

  6. 在“Filter labels(过滤标签)”字段中,键入新标签的名称,并单击 Create new label(创建新标签)

    添加运行器标签

将创建自定义标签并分配给自托管运行器。 可以从自托管的运行器中删除自定义标签,但当前无法手动删除。 未分配给运行器的任何未使用标签将在 24 小时内被自动删除。

分配标签给自托管的运行器

  1. Navigate to where your self-hosted runner is registered:

    • In an organization or repository: navigate to the main page and click Settings.
    • If using an enterprise account: navigate to your enterprise account by visiting https://github.com/enterprises/ENTERPRISE-NAME, replacing ENTERPRISE-NAME with your enterprise account's name. In the enterprise sidebar, Policies.
  2. Navigate to the GitHub Actions settings:

    • In an organization or repository: click Actions in the left sidebar.

      操作设置

    • If using an enterprise account: click Actions under " Policies".

  3. Locate the list of runners under "Self-hosted runners".

  4. If your runner is in a group, locate the runner group and click to view the list of runners.

    List runner group

  5. Locate the runner you want to update, and click to view the label selection menu. 此菜单显示您的自托管运行器可用的所有自定义标签。 已分配给自托管运行器的标签旁边有

    更改运行器标签

  6. 单击标签以将其分配给您的自托管运行器。

删除自托管运行器中的自定义标签

  1. Navigate to where your self-hosted runner is registered:

    • In an organization or repository: navigate to the main page and click Settings.
    • If using an enterprise account: navigate to your enterprise account by visiting https://github.com/enterprises/ENTERPRISE-NAME, replacing ENTERPRISE-NAME with your enterprise account's name. In the enterprise sidebar, Policies.
  2. Navigate to the GitHub Actions settings:

    • In an organization or repository: click Actions in the left sidebar.

      操作设置

    • If using an enterprise account: click Actions under " Policies".

  3. Locate the list of runners under "Self-hosted runners".

  4. If your runner is in a group, locate the runner group and click to view the list of runners.

    List runner group

  5. Locate the runner you want to update, and click to view the label selection menu. 此菜单显示您的自托管运行器可用的所有自定义标签。 已分配给自托管运行器的标签旁边有

    更改运行器标签

  6. 单击分配的标签以将其从您的自托管运行器中删除。 未分配给运行器的任何未使用标签将在 24 小时内被自动删除。

使用配置脚本创建和分配标签

您可以使用自托管运行器上的配置脚本创建和分配自定义标签。 例如,此命令将名为 gpu 的标签分配给自托管运行器。

./config.sh --labels gpu

如果标签不存在,则创建该标签。 您也可以使用此方法将默认标签分配给运行器,例如 x64linux.。 使用配置脚本分配默认标签后, GitHub Actions 会接受它们,而不验证运行器是否实际使用该操作系统或架构。

您可以使用逗号分隔来分配多个标签。 例如:

./config.sh --labels gpu,x64,linux

注: 如果替换现有的运行器,则必须重新分配任何自定义标签。

Did this doc help you?