Skip to main content

Using self-hosted runners in a workflow

To use self-hosted runners in a workflow, you can use labels or groups to specify the runner for a job.

Viewing available runners for a repository

리포지토리에 repo: write 액세스 권한이 있는 경우 리포지토리에서 사용할 수 있는 실행기 목록을 볼 수 있습니다.

  1. GitHub에서 리포지토리의 기본 페이지로 이동합니다.

  2. 리포지토리 이름 아래에서 작업을 클릭합니다.

    "github/docs" 리포지토리의 탭 스크린샷. "작업" 탭은 주황색 윤곽선으로 강조 표시됩니다.

  3. 왼쪽 사이드바의 "관리" 섹션에서 실행기를 클릭합니다.

  4. Click the Self hosted tab at the top of the list of runners.

  5. 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 Actions Runner Controller.

  6. 실행기 레이블을 복사사하여 워크플로에서 사용하려면, 실행기 오른쪽에 있는 을 클릭한 다음 레이블 복사를 클릭합니다.

참고 항목

엔터프라이즈와 조직 소유자 및 “조직 실행기와 실행기 그룹 관리” 권한을 가진 사용자는 이 페이지에서 새 실행기를 만들 수 있습니다. 새 실행기를 만들려면 실행기 목록의 오른쪽 상단에 있는 새 실행기를 클릭하여 리포지토리에 실행기를 추가합니다.

자세한 내용은 Managing larger runnersAdding 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, or macOS: Applied depending on operating system.
  • x64, ARM, or ARM64: 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 실행기 그룹은 ubuntu-20.04-16core 레이블이 할당된 Ubuntu 실행기로 채워집니다. runs-on 키가 group, labels와 결합되어 작업이 일치하는 레이블이 있는 그룹 내에서 사용 가능한 모든 실행기로 라우팅됩니다.

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