Skip to main content

Using GitHub-hosted runners

You can assign a job to run on a virtual machine hosted by GitHub.

Using a GitHub-hosted runner

To use a GitHub-hosted runner, create a job and use runs-on to specify the type of runner that will process the job, such as ubuntu-latest, windows-latest, or macos-latest. For the full list of runner types, see GitHub-hosted runners reference. If you have repo: write access to a repository, you can view a list of the runners available to use in workflows in the repository. For more information, see Viewing available runners for a repository.

When the job begins, GitHub automatically provisions a new VM for that job. All steps in the job execute on the VM, allowing the steps in that job to share information using the runner's filesystem. You can run workflows directly on the VM or in a Docker container. When the job has finished, the VM is automatically decommissioned.

The following diagram demonstrates how two jobs in a workflow are executed on two different GitHub-hosted runners.

Diagram of a workflow that consists of two jobs. One job runs on Ubuntu and the other runs on Windows.

The following example workflow has two jobs, named Run-npm-on-Ubuntu and Run-PSScriptAnalyzer-on-Windows. When this workflow is triggered, GitHub provisions a new virtual machine for each job.

  • The job named Run-npm-on-Ubuntu is executed on a Linux VM, because the job's runs-on: specifies ubuntu-latest.
  • The job named Run-PSScriptAnalyzer-on-Windows is executed on a Windows VM, because the job's runs-on: specifies windows-latest.
YAML
name: Run commands on different operating systems
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  Run-npm-on-Ubuntu:
    name: Run npm on Ubuntu
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '14'
      - run: npm help

  Run-PSScriptAnalyzer-on-Windows:
    name: Run PSScriptAnalyzer on Windows
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install PSScriptAnalyzer module
        shell: pwsh
        run: |
          Set-PSRepository PSGallery -InstallationPolicy Trusted
          Install-Module PSScriptAnalyzer -ErrorAction Stop
      - name: Get list of rules
        shell: pwsh
        run: |
          Get-ScriptAnalyzerRule

While the job runs, the logs and output can be viewed in the GitHub UI:

Screenshot of a workflow run. The steps for the "Run PSScriptAnalyzer on Windows" job are displayed.

L’exĂ©cuteur GitHub Actions est une application open source. Vous pouvez signaler et contribuer Ă  rĂ©soudre des problĂšmes dans le rĂ©fĂ©rentiel de l’exĂ©cuteur.

Viewing available runners for a repository

Si vous avez un accÚs repo: write à un référentiel, vous pouvez visualiser une liste des exécuteurs disponibles pour le référentiel.

  1. Sur GitHub, accédez à la page principale du référentiel.

  2. Sous le nom de votre dépÎt, cliquez sur Actions.

    Capture d’écran des onglets du rĂ©fĂ©rentiel « github/docs ». L’onglet « Actions » est mis en surbrillance avec un encadrĂ© orange.

  3. Dans la barre latérale gauche, sous la section « Gestion », cliquez sur Exécuteurs.

  4. Review the list of available GitHub-hosted runners for the repository.

  5. Si vous le souhaitez, pour copier l’étiquette d’un exĂ©cuteur pour l’utiliser dans un flux de travail, cliquez sur Ă  droite de l’exĂ©cuteur, puis cliquez sur Copier l’étiquette.

Remarque

Les propriĂ©taires d’entreprise et d’organisation et les utilisateurs disposant de l’autorisation « GĂ©rer les exĂ©cuteurs d’organisation et les groupes d’exĂ©cuteurs » peuvent crĂ©er de nouveaux exĂ©cuteurs Ă  partir de cette page. Pour crĂ©er un exĂ©cuteur, cliquez sur Nouvel exĂ©cuteur en haut Ă  droite de la liste des exĂ©cuteurs pour en ajouter au rĂ©fĂ©rentiel.

Pour plus d’informations, consultez Managing larger runners et Adding self-hosted runners. Pour plus d’informations sur les rĂŽles d’organisation personnalisĂ©s, consultez À propos des rĂŽles d'organisation personnalisĂ©s.