Skip to main content

Configuring Build Hub for GitHub Actions

概要

Create a personal access token, a Bitrise machine pool, and then configure your GitHub Actions workflow to successfully run it on Bitrise Build Hub infrastructure.

To successfully use Build Hub for GitHub Actions, you need to:

  1. Create a GitHub personal access token, either a classic or a fine-grained one, depending on your requirements.

  2. Create a machine pool on Bitrise.

  3. Configure your GitHub Actions workflow to use Bitrise infrastructure for your builds.

Creating GitHub personal access tokens for Build Hub

To authenticate Build Hub to GitHub Actions, you need personal access tokens on GitHub. You can use either a classic access token or a fine-grained access token, depending on your needs. Read more on how authentication works: Authentication for Build Hub.

To create the token on GitHub:

Fine-grained

Classic

Token availability

Only organization-level target scopes can have fine-grained access tokens: [認証].

  1. Go through the process described here until you get to selecting a resource owner.

  2. Select a resource owner: it should be the organization.

    Authorization

    The organization might require authorization for the token: for example, you might be prompted to log in via SSO.

  3. Under Repository access, select All repositories.

  4. Under Permissions, select Organizations.

  5. Click Add permissions.

  6. Select Self-hosted runners.

  7. Set the access to Read and write.

    2026-02-06-github-token.png
  8. Click Generate token.

  9. Copy your personal access token: you won't be able to see it again but you need it when creating a machine pool.

Target scopes

Check the required permissions for the different target scopes: [認証].

  1. Go through the process described here until you get to selecting the scopes.

  2. Select the right scope: it depends on the target scope you need for your machine pool.

    • GitHub Cloud organization (https://github.com/<org>) and GHE organization (https://<hostname>/<org>): org:admin

    • GitHub Enterprise (GHE) Cloud (https://github.com/enterprises/<enterprise>) and GHE Server (https://<hostname>/enterprises/<enterprise>): manage_runners:enterprise.

    • GitHub Cloud repository (https://github.com/<owner>/<repo>) and GHE repository (https://<hostname>/<owner>/<repo>): workflow.

  3. Click Generate token.

  4. Copy your personal access token: you won't be able to see it again but you need it when creating a machine pool.

マシンプールの作成

BitriseハードウェアでCIビルドを実行できるマシンプールを作成します。

  1. ワークスペースの設定ページを開いて、以下を選択します ビットライズ・クラウド

  2. クリック マシンプール

  3. プールに一意の名前を設定します。

  4. で画像を選択します [イメージ] ドロップダウンメニューと必要なマシンの数 マシン数 フィールド。

    で画像を確認できます スタックレポートページ

    2026-02-04-machine-pool-image.png
  5. マシンタイプを選択します。

    Bitriseマシンの詳細については、以下をご覧ください マシンを構築する

  6. ローリングアップデートの割合を設定します。これは、再構成後に同時に再起動されるマシンの数です。

  7. 完了したら、をクリックします [次へ]

  8. オプションで、ラベルを使用してプールを整理および分類できます。

    デフォルトでは、Bitriseはプール名、イメージ、マシンタイプのラベルを提案します。これらはいつでも変更できます

  9. オプションで、ウォームアップスクリプトを追加してビルド環境をカスタマイズします。完了したら、をクリックします [次へ]

    ウォームアップスクリプトが必要ない場合は空のままにしてください。

    0 以外の終了コード

    エラーが発生した場合は、必ず 0 以外の終了コードを返すようにしてください。スクリプトが失敗するのは、スクリプトが 0 以外の終了コードを返した場合だけです

  10. [選択] GitHub から CI ツール ドロップダウンメニュー。

  11. ターゲットスコープ URL を設定します。

    ターゲットスコープの詳細については、こちらをご覧ください。 ターゲットスコープ

    20260204-machine-pool-target-scope.png
  12. GitHub 個人アクセストークンを追加します。

  13. オプションで、ランナーバージョンとランナーグループを追加します。

    • ランナーのバージョンは v2.328.0 のように正確である必要があります。ランナーバージョンを指定しない場合、最新バージョンが使用されます

    • ランナーグループ 複数のランナーを集め、その周囲にセキュリティ境界を設けるために使用されます。

  14. クリック プールを作成

GitHub アクションワークフローを設定する

マシンプールを正常に作成したら、ビルドの実行時にマシンプールを使用するように GitHub Actions ワークフローを設定する必要があります。

を使う runs-on Bitrise マシンを指定するためのワークフロー内のプロパティ。ランナーに割り当てられたラベル、グループメンバーシップ、またはこれらの組み合わせに基づいてランナーをターゲットにすることができます

  1. GitHub リポジトリを開いて選択してください アクション

  2. 左側で、ワークフローの名前をクリックします。

  3. ワークフローの名前の下で、をクリックします デプロイ.yml

  4. を追加 runs-on Build Hub で実行したいジョブのプロパティ。

    • ランナーグループがない場合は、 self-hosted 値として:

      jobs:
        build:
          runs-on: self-hosted
    • If you use a runner group, the value should be group:<group-name>. For example:

      jobs:
        build:
          runs-on: 
            group: Bitrise-M4Pro
    • GitHub では、設定でラベルを使用できます。例えば、以下の設定では 3 つのラベルをすべて持つランナーのみが許可されます

      jobs:
        build:
          runs-on: [self-hosted, linux, x64, gpu]
      

      ラベルは次の場合に作成および編集できます。 マシンプールの作成または更新

についての詳細は runs-on プロパティ、チェックして GitHub アクションドキュメンテーション