Skip to main content

Using labels with self-hosted runners

You can use labels to organize your self-hosted runners based on their characteristics.

For information on how to use labels to route jobs to specific types of self-hosted runners, see "Using self-hosted runners in a workflow."

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

  • 用户存储库:你必须是存储库所有者。
  • 组织:你必须是组织所有者。
  • 组织存储库:你必须是组织所有者,或者拥有对存储库的管理员访问权限。

Creating a custom label

  1. 导航到已注册自托管运行器组的组织或存储库的主页。
  2. 单击“ 设置”。
  3. In the left sidebar, click Actions, then click Runners.
  4. 在运行器列表中,单击要配置的运行器。
  5. In the "Labels" section, click .
  6. In the "Find or create a label" field, type the name of your new label and click Create new label. The custom label is created and assigned to the self-hosted runner. Custom labels can be removed from self-hosted runners, but they currently can't be manually deleted. 未分配给运行器的任何未使用标签将在 24 小时内被自动删除。

Assigning a label to a self-hosted runner

  1. 导航到已注册自托管运行器组的组织或存储库的主页。
  2. 单击“ 设置”。
  3. In the left sidebar, click Actions, then click Runners.
  4. 在运行器列表中,单击要配置的运行器。
  5. 在“Labels(标签)”部分,单击
  6. To assign a label to your self-hosted runner, in the "Find or create a label" field, click the label.

Removing a custom label from a self-hosted runner

  1. 导航到已注册自托管运行器组的组织或存储库的主页。
  2. 单击“ 设置”。
  3. In the left sidebar, click Actions, then click Runners.
  4. 在运行器列表中,单击要配置的运行器。
  5. 在“Labels(标签)”部分,单击
  6. In the "Find or create a label" field, assigned labels are marked with the icon. Click on a marked label to unassign it from your self-hosted runner.

Using the configuration script to create and assign labels

You can use the configuration script on the self-hosted runner to create and assign custom labels. For example, this command assigns a label named gpu to the self-hosted runner.

./config.sh --labels gpu

The label is created if it does not already exist. You can also use this approach to assign the default labels to runners, such as x64 or linux. When default labels are assigned using the configuration script, GitHub Actions accepts them as given and does not validate that the runner is actually using that operating system or architecture.

You can use comma separation to assign multiple labels. For example:

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

Note: If you replace an existing runner, then you must reassign any custom labels.