You can target self-hosted runners for use in a workflow based on the labels assigned to the runners, or their group membership, or a combination of these.
Внимание
Runner Scale Sets do not support multiple labels, only the name of the runner can be used in place of a label. See Deploying runner scale sets with Actions Runner Controller.
About self-hosted runner labels
Labels allow you to send workflow jobs to specific types of self-hosted runners, based on their shared characteristics. For example, if your job requires a particular hardware component or software package, you can assign a custom label to a runner and then configure your job to only execute on runners with that label.
Чтобы указать локальное средство выполнения тестов для задания, настройте runs-on
в файле рабочего процесса, используя метки локального средства выполнения тестов.
У локальных модулей выполнения может быть self-hosted
метка. При настройке локального runner по умолчанию мы будем включать метку self-hosted
. Вы можете передать --no-default-labels
флаг, чтобы предотвратить применение локальной метки. Метки можно использовать для создания параметров целевого назначения для средств выполнения, таких как операционная система или архитектура, мы рекомендуем предоставить массив меток, начинающихся с self-hosted
(это должно быть указано сначала), а затем включить дополнительные метки по мере необходимости. При указании массива меток задания будут помещены в очередь в средства выполнения тестов, которые имеют все указанные метки.
Обратите внимание, что контроллер runner действий не поддерживает несколько меток и не поддерживает self-hosted
метку.
For information on creating custom and default labels, see Using labels with self-hosted runners.
About self-hosted runner groups
For self-hosted runners defined at the organization or enterprise levels, you can group your runners with shared characteristics into a single runner group and then configure your job to target the runner group.
To specify a self-hosted runner group for your job, configure runs-on.group
in your workflow file.
For information on creating and managing runner groups, see Managing access to self-hosted runners using groups.
Viewing available runners for a repository
Если у вас есть repo: write
доступ к репозиторию, вы можете просмотреть список средств выполнения, доступных в репозитории.
-
На GitHubперейдите на главную страницу репозитория.
-
Под именем репозитория щелкните Actions.
-
В левой боковой панели в разделе "Управление" щелкните Runners.
-
Click the Self hosted tab at the top of the list of runners.
-
Review the list of available self-hosted runners for the repository. This list includes both self-hosted runners and runner scale sets created with Actions Runner Controller. For more information, see Сведения о контроллере запуска действий.
-
При необходимости, чтобы скопировать метку бегуна, чтобы использовать ее в рабочем процессе, щелкните справа от средства выполнения, а затем нажмите кнопку "Копировать метку".
Примечание.
Корпоративные и владелец организации могут создавать средства выполнения на этой странице. Чтобы создать нового бегуна, нажмите кнопку Создать runner в правом верхнем углу списка бегунов, чтобы добавить в репозиторий средства выполнения.
Дополнительные сведения см. в разделе [AUTOTITLE и Managing larger runners](/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners).
Using default labels to route jobs
A self-hosted runner automatically receives certain labels when it is added to GitHub Actions. These are used to indicate its operating system and hardware platform:
self-hosted
: Default label applied to self-hosted runners.linux
,windows
, ormacOS
: Applied depending on operating system.x64
,ARM
, orARM64
: Applied depending on hardware architecture.
You can use your workflow's YAML to send jobs to a combination of these labels. In this example, a self-hosted runner that matches all three labels will be eligible to run the job:
runs-on: [self-hosted, linux, ARM64]
self-hosted
- Run this job on a self-hosted runner.linux
- Only use a Linux-based runner.ARM64
- Only use a runner based on ARM64 hardware.
To create individual self-hosted runners without the default labels, pass the --no-default-labels
flag when you create the runner. Actions Runner Controller does not support multiple labels.
Using custom labels to route jobs
You can create custom labels and assign them to your self-hosted runners at any time. Custom labels let you send jobs to particular types of self-hosted runners, based on how they're labeled.
For example, if you have a job that requires a specific type of graphics hardware, you can create a custom label called gpu
and assign it to the runners that have the hardware installed. A self-hosted runner that matches all the assigned labels will then be eligible to run the job.
This example shows a job that combines default and custom labels:
runs-on: [self-hosted, linux, x64, gpu]
self-hosted
- Run this job on a self-hosted runner.linux
- Only use a Linux-based runner.x64
- Only use a runner based on x64 hardware.gpu
- This custom label has been manually assigned to self-hosted runners with the GPU hardware installed.
These labels operate cumulatively, so a self-hosted runner must have all four labels to be eligible to process the job.
Using groups to route jobs
В этом примере средства запуска Ubuntu добавлены в группу с именем ubuntu-runners
. Ключ runs-on
отправляет задание любому доступному ubuntu-runners
средству выполнения в группе:
name: learn-github-actions
on: [push]
jobs:
check-bats-version:
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- run: npm install -g bats
- run: bats -v
Using labels and groups to route jobs
При сочетании групп и меток средство выполнения должно соответствовать обоим требованиям, чтобы иметь право на выполнение задания.
В этом примере вызываемая ubuntu-runners
группа runner заполняется средствами запуска Ubuntu, которые также были назначены меткой ubuntu-20.04-16core
. Ключ runs-on
объединяется group
и labels
таким образом, чтобы задание перенаправлялось на любой доступный runner в группе, которая также имеет соответствующую метку:
name: learn-github-actions
on: [push]
jobs:
check-bats-version:
runs-on:
group: ubuntu-runners
labels: ubuntu-20.04-16core
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- run: npm install -g bats
- run: bats -v
Routing precedence for self-hosted runners
When routing a job to a self-hosted runner, GitHub looks for a runner that matches the job's runs-on
labels and groups:
- If GitHub finds an online and idle runner that matches the job's
runs-on
labels and groups, the job is then assigned and sent to the runner.- If the runner doesn't pick up the assigned job within 60 seconds, the job is re-queued so that a new runner can accept it.
- If GitHub doesn't find an online and idle runner that matches the job's
runs-on
labels and groups, then the job will remain queued until a runner comes online. - If the job remains queued for more than 24 hours, the job will fail.
Workflow run continuity
Если службы GitHub Actions временно недоступны, выполнение рабочего процесса отменяется, если он не был помещен в очередь в течение 30 минут после активации. Например, если рабочий процесс активируется и службы GitHub Actions недоступны в течение 31 минуты или дольше, выполнение рабочего процесса не будет обработано.