有关如何使用标签将作业路由到特定类型的自托管运行器的信息,请参阅“在工作流程中使用自托管的运行器”。
自托管运行器可位于仓库、组织或GitHub 上的企业帐户设置中。 要管理自托管运行器,您必须拥有以下权限,具体取决于添加自托管运行器的位置:
- 用户仓库:您必须是仓库所有者。
- 组织:您必须是组织所有者。
- 组织仓库:您必须是组织所有者或者拥有该仓库的管理员权限。
创建自定义标签
-
Navigate to the main page of the organization or repository where your self-hosted runner group is registered.
-
Click Settings.
-
In the left sidebar, click Actions, then click Runners.
-
In the list of runners, click the runner you'd like to configure.
-
在“Labels(标签)”部分,单击 。
-
在“Find or create a label(查找或创建标签)”字段中,键入新标签的名称,并单击 Create new label(创建新标签)。 将创建自定义标签并分配给自托管运行器。 可以从自托管的运行器中删除自定义标签,但当前无法手动删除。 未分配给运行器的任何未使用标签将在 24 小时内被自动删除。
分配标签给自托管的运行器
-
Navigate to the main page of the organization or repository where your self-hosted runner group is registered.
-
Click Settings.
-
In the left sidebar, click Actions, then click Runners.
-
In the list of runners, click the runner you'd like to configure.
-
在“Labels(标签)”部分,单击 。
-
要将标签分配给您的自托管运行器,在“Find or create a label(查找或创建标签)”字段中单击标签。
删除自托管运行器中的自定义标签
-
Navigate to the main page of the organization or repository where your self-hosted runner group is registered.
-
Click Settings.
-
In the left sidebar, click Actions, then click Runners.
-
In the list of runners, click the runner you'd like to configure.
-
在“Labels(标签)”部分,单击 。
-
在“Find or create a label(查找或创建标签)”字段中,分配的标签使用 图标来标记。 单击标记的标签以将其从您的自托管运行器取消分配。
使用配置脚本创建和分配标签
您可以使用自托管运行器上的配置脚本创建和分配自定义标签。 例如,此命令将名为 gpu
的标签分配给自托管运行器。
./config.sh --labels gpu
如果标签不存在,则创建该标签。 您也可以使用此方法将默认标签分配给运行器,例如 x64
或 linux
.。 使用配置脚本分配默认标签后, GitHub Actions 会接受它们,而不验证运行器是否实际使用该操作系统或架构。
您可以使用逗号分隔来分配多个标签。 例如:
./config.sh --labels gpu,x64,linux
注: 如果替换现有的运行器,则必须重新分配任何自定义标签。