Skip to main content

Getting started with self-hosted runners for your enterprise

You can configure a runner machine for your enterprise so your developers can start automating workflows with GitHub Actions.

Who can use this feature

Enterprise owners can configure policies for GitHub Actions and add self-hosted runners to the enterprise.

About self-hosted runners for GitHub Actions

GitHub Actions allows members of your enterprise to improve productivity by automating every phase of the software development workflow. For more information, see "About GitHub Actions for enterprises."

With GitHub Actions, developers can write and combine individual tasks called actions to create custom workflows. To enable GitHub Actions for your enterprise, you must host at least one machine to execute jobs. This machine is called a self-hosted runner. セルフホステッド ランナーは、物理または仮想にでき、コンテナー内、オンプレミス、またはクラウドに配置できます。 ランナーマシンは、GitHub Actionsのセルフホストランナーアプリケーションを使ってGitHub AEに接続します。 Self-hosted runners can run Linux, Windows, or macOS. For more information, see "About self-hosted runners."

This guide shows you how to apply a centralized management approach to self-hosted runners for GitHub Actions in your enterprise. In the guide, you'll complete the following tasks.

  1. Configure a limited policy to restrict the actions that can run within your enterprise
  2. Deploy a self-hosted runner for your enterprise
  3. Create a group to manage access to the runners available to your enterprise
  4. Optionally, further restrict the repositories that can use the runner
  5. Optionally, build custom tooling to automatically scale your self-hosted runners

You'll also find additional information about how to monitor and secure your self-hosted runners, how to access actions from GitHub.com, and how to customize the software on your runner machines.

After you finish the guide, members of your enterprise will be able to run workflow jobs from GitHub Actions on a self-hosted runner machine.

Prerequisites

1. Configure policies for GitHub Actions

First, enable GitHub Actions for all organizations, and configure a policy to restrict the actions that can run within your enterprise on GitHub AE. Optionally, organization owners can further restrict these policies for each organization.

  1. GitHub AE の右上で、ご自分のプロファイル写真をクリックしてから、 [Enterprise 設定] をクリックします。 GitHub AE のプロファイル写真のドロップダウン メニューの [自分の Enterprise]

  2. Enterprise サイドバーで、 [ポリシー] をクリックします。 [Enterprise アカウント] サイドバーの [ポリシー] タブ

  3. [ ポリシー] で、 [アクション] をクリックします。

  4. Under "Policies", select Enable for all organizations.

    Screenshot of "Enable for all organizations" policy for GitHub Actions

  5. Select [Allow select actions](選択したアクションを許可する) and Allow actions created by GitHub to allow local actions, and actions created by GitHub.

    Screenshot of "Allow select actions" and "Allow actions created by GitHub" for GitHub Actions

  6. Click Save.

You can configure additional policies to restrict the actions available to enterprise members. For more information, see "Enforcing policies for GitHub Actions in your enterprise."

2. Deploy the self-hosted runner for your enterprise

Next, add a self-hosted runner to your enterprise. GitHub AE will guide you through installation of the necessary software on the runner machine. After you deploy the runner, you can verify connectivity between the runner machine and your enterprise.

Adding the self-hosted runner

  1. GitHub AE の右上で、ご自分のプロファイル写真をクリックしてから、 [Enterprise 設定] をクリックします。 GitHub AE のプロファイル写真のドロップダウン メニューの [自分の Enterprise]

  2. Enterprise サイドバーで、 [ポリシー] をクリックします。 [Enterprise アカウント] サイドバーの [ポリシー] タブ

  3. [ ポリシー] で、 [アクション] をクリックします。

  4. [Runners](ランナー) タブをクリックします。

  5. Click New runner.

  6. 使用するセルフホスト ランナー マシンのオペレーティング システム イメージとアーキテクチャを選択します。

  7. ランナーアプリケーションをダウンロードして、使用するセルフホストランナーのマシンにインストールする方法が表示されます。

    セルフホストランナーのマシンでシェルを開き、表示順に従ってシェルコマンドを実行してください。

    注: Windows で、セルフホスト ランナー アプリケーションをサービスとしてインストールする場合は、シェルを管理者権限でオープンしなければなりません。 また、C:\actions-runner をセルフホスト ランナー アプリケーション用のディレクトリとして使用し、Windows のシステム アカウントでランナー ディレクトリにアクセスできるようにすることをお勧めします。

    この指示に従えば、以下のタスクが完了します。

    • セルフホストランナーアプリケーションのダウンロードと展開。
    • config スクリプトを実行してセルフホスト ランナー アプリケーションを設定し、GitHub Actions に登録します。 config スクリプトには、登録先の URL と、リクエストを認証してもらうための自動的に生成された時間制限付きのトークンが必要です。
    • セルフホストランナーアプリケーションを実行して、マシンをGitHub Actionsに接続します。

Checking that your self-hosted runner was successfully added

After completing the steps to add a self-hosted runner, the runner and its status are now listed under "Self-hosted runners".

The self-hosted runner application must be active for the runner to accept jobs. When the runner application is connected to GitHub AE and ready to receive jobs, you will see the following message on the machine's terminal.

√ Connected to GitHub

2019-10-24 05:45:56Z: Listening for Jobs

3. Manage access to the self-hosted runner using a group

You can create a runner group to manage access to the runner that you added to your enterprise. You'll use the group to choose which organizations can execute jobs from GitHub Actions on the runner.

GitHub AE adds all new runners to a group. Runners can be in one group at a time. By default, GitHub AE adds new runners to the "Default" group.

  1. GitHub AE の右上で、ご自分のプロファイル写真をクリックしてから、 [Enterprise 設定] をクリックします。 GitHub AE のプロファイル写真のドロップダウン メニューの [自分の Enterprise]
  2. Enterprise サイドバーで、 [ポリシー] をクリックします。 [Enterprise アカウント] サイドバーの [ポリシー] タブ
  3. [ ポリシー] で、 [アクション] をクリックします。
  4. [ランナー グループ] タブをクリックします。
  5. Click New runner group.
  6. Under "Group name", type a name for your runner group.
  7. To choose a policy for organization access, under "Organization access", select the Organization access drop-down, and click Selected organizations.
  8. To the right of the drop-down with the organization access policy, click .
  9. Select the organizations you'd like to grant access to the runner group.
  10. Click Create group to create the group and apply the policy.
  11. Click the "Runners" tab.
  12. In the list of runners, click the runner that you deployed in the previous section.
  13. Click Edit.
  14. Click Runner groups .
  15. In the list of runner groups, click the name of the group that you previously created.
  16. Click Save to move the runner to the group.

You've now deployed a self-hosted runner that can run jobs from GitHub Actions within the organizations that you specified.

4. Further restrict access to the self-hosted runner

Optionally, organization owners can further restrict the access policy of the runner group that you created. For example, an organization owner could allow only certain repositories in the organization to use the runner group.

For more information, see "Managing access to self-hosted runners using groups."

5. Automatically scale your self-hosted runners

Optionally, you can build custom tooling to automatically scale the self-hosted runners for your enterprise. For example, your tooling can respond to webhook events from your enterprise to automatically scale a cluster of runner machines. For more information, see "Autoscaling with self-hosted runners."

Next steps

Further reading