{"meta":{"title":"ジョブで使用されるコンテナーのカスタマイズ","intro":"セルフホステッド ランナーでジョブのコンテナーを呼び出す方法をカスタマイズできます。","product":"GitHub Actions","breadcrumbs":[{"href":"/ja/enterprise-cloud@latest/actions","title":"GitHub Actions"},{"href":"/ja/enterprise-cloud@latest/actions/how-tos","title":"方法"},{"href":"/ja/enterprise-cloud@latest/actions/how-tos/manage-runners","title":"ランナーを管理する"},{"href":"/ja/enterprise-cloud@latest/actions/how-tos/manage-runners/self-hosted-runners","title":"セルフホステッド ランナー"},{"href":"/ja/enterprise-cloud@latest/actions/how-tos/manage-runners/self-hosted-runners/customize-containers","title":"コンテナーをカスタマイズする"}],"documentType":"article"},"body":"# ジョブで使用されるコンテナーのカスタマイズ\n\nセルフホステッド ランナーでジョブのコンテナーを呼び出す方法をカスタマイズできます。\n\n> \\[!NOTE]\n> この機能は現在 パブリック プレビュー であり、変更される可能性があります。\n\n## コンテナーのカスタマイズについて\n\nGitHub Actions では、ワークフロー ファイルの `container:` ステートメントを使用して、コンテナー内でジョブを実行できます。 詳しくは、「[コンテナ内でのジョブの実行](/ja/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container)」をご覧ください。 コンテナー ベースのジョブを処理するために、セルフホステッド ランナーではジョブごとにコンテナーが作成されます。\n\nGitHub Actions では、セルフホステッド ランナーによってコンテナーを作成する方法をカスタマイズできるコマンドがサポートされています。 たとえば、これらのコマンドを使用して、Kubernetes または Podman を介してコンテナーを管理できます。また、コンテナーを呼び出すために使用される `docker run` または `docker create` コマンドをカスタマイズすることもできます。 カスタマイズ コマンドはスクリプトによって実行されます。スクリプトは、ランナーで特定の環境変数が設定されている場合、自動的にトリガーされます。 詳細については、後述する「[カスタマイズ スクリプトのトリガー](#triggering-the-customization-script)」を参照してください。\n\nこのカスタマイズは、Linux ベースのセルフホステッド ランナーにのみ使用でき、ルート ユーザー アクセスは必要ありません。\n\n## コンテナーのカスタマイズ コマンド\n\nGitHub Actions には、コンテナーをカスタマイズするための次のコマンドが含まれています。\n\n* [\n  `prepare_job`\n  ](/ja/enterprise-cloud@latest/actions/how-tos/manage-runners/self-hosted-runners/customize-containers#prepare_job): ジョブの開始時に呼び出されます。\n* [\n  `cleanup_job`\n  ](/ja/enterprise-cloud@latest/actions/how-tos/manage-runners/self-hosted-runners/customize-containers#cleanup_job): ジョブの終了時に呼び出されます。\n* [\n  `run_container_step`\n  ](/ja/enterprise-cloud@latest/actions/how-tos/manage-runners/self-hosted-runners/customize-containers#run_container_step): ジョブ内のコンテナー アクションごとに 1 回呼び出されます。\n* [\n  `run_script_step`\n  ](/ja/enterprise-cloud@latest/actions/how-tos/manage-runners/self-hosted-runners/customize-containers#run_script_step): コンテナー アクション以外のステップを実行します。\n\nこれらのカスタマイズ コマンドはそれぞれ、独自の JSON ファイルで定義する必要があります。 ファイル名は、拡張子 `.json` を付けたコマンド名と一致する必要があります。 たとえば、`prepare_job` コマンドは、`prepare_job.json` で定義されます。 この後、これらの JSON ファイルは、メイン `index.js` スクリプトの一部として、セルフホステッド ランナーでまとめて実行されます。 このプロセスについては、「[カスタマイズ スクリプトの生成](#generating-the-customization-script)」で詳しく説明します。\n\nこれらのコマンドには、構成引数も含まれます。詳細については、以下で説明します。\n\n### `prepare_job`\n\n`prepare_job` コマンドは、ジョブの開始時に呼び出されます。\nGitHub Actions は、そのジョブに含まれる任意のジョブ コンテナーまたはサービス コンテナーを渡します。 このコマンドは、ジョブ内にサービスまたはジョブ コンテナーがある場合に呼び出されます。\n\nGitHub Actions は、 `prepare_job` コマンドで次のタスクを実行することを前提としています。\n\n* 必要に応じて、前の作業から不要なものを削除する。\n* 必要に応じて、ネットワークを作成する。\n* ジョブとサービス コンテナーをプルする。\n* ジョブ コンテナーを開始する。\n* サービスコンテナを開始する。\n* GitHub Actions必要な情報を応答ファイルに書き込みます。\n  * 必須: コンテナーが `alpine` Linux コンテナーであるかどうかを示します (`isAlpine` ブール値を使用)。\n  * 省略可能: ジョブ コンテキストに設定するコンテキスト フィールド。それ以外の場合、ユーザーはそれらを使用できなくなります。 詳しくは、「[コンテキスト リファレンス](/ja/enterprise-cloud@latest/actions/reference/workflows-and-actions/contexts#job-context)」をご覧ください。\n* 正常性チェックが成功し、ジョブまたはサービス コンテナーが開始されると、`0` を返します。\n\n#### `prepare_job` の引数\n\n* `jobContainer`: **省略可能**。 指定されたジョブ コンテナーに関する情報を含むオブジェクト。\n  * `image`: **必須**。 Docker イメージを含む文字列。\n  * `workingDirectory`: **必須**。 作業ディレクトリの絶対パスを含む文字列。\n  * `createOptions`: **省略可能**。 YAML で指定された省略可能な \"*create*\" オプション。 詳しくは、「[コンテナ内でのジョブの実行](/ja/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#example-running-a-job-within-a-container)」をご覧ください。\n  * `environmentVariables`: **省略可能**。 主要な環境変数のマップを設定します。\n  * `userMountVolumes`: **省略可能**。 YAML で設定されたユーザー マウント ボリュームの配列。 詳しくは、「[コンテナ内でのジョブの実行](/ja/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#example-running-a-job-within-a-container)」をご覧ください。\n    * `sourceVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのソース パス。\n    * `targetVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのターゲット パス。\n    * `readOnly`: **必須**。 マウントを読み取り専用にする必要があるかどうかを決定します。\n  * `systemMountVolumes`: **必須**。 コンテナーにマウントするマウントの配列 (上記と同じフィールド)。\n    * `sourceVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのソース パス。\n    * `targetVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのターゲット パス。\n    * `readOnly`: **必須**。 マウントを読み取り専用にする必要があるかどうかを決定します。\n  * `registry`\n    **省略可能**。 プライベート コンテナー レジストリの Docker レジストリ資格情報。\n    * `username`: **省略可能**。 レジストリ アカウントのユーザー名。\n    * `password`: **省略可能**。 レジストリ アカウントのパスワード。\n    * `serverUrl`: **省略可能**。 レジストリのURL。\n  * `portMappings`: **省略可能**。 コンテナーにマップする *source:target* ポートのキー値ハッシュ。\n* `services`: **省略可能**。 スピン アップするサービス コンテナーの配列。\n  * `contextName`: **必須**。 ジョブ コンテキスト内のサービスの名前。\n  * `image`: **必須**。 Docker イメージを含む文字列。\n  * `createOptions`: **省略可能**。 YAML で指定された省略可能な \"*create*\" オプション。 詳しくは、「[コンテナ内でのジョブの実行](/ja/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#example-running-a-job-within-a-container)」をご覧ください。\n  * `environmentVariables`: **省略可能**。 主要な環境変数のマップを設定します。\n  * `userMountVolumes`: **省略可能**。 コンテナーにマウントするマウントの配列 (上記と同じフィールド)。\n    * `sourceVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのソース パス。\n    * `targetVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのターゲット パス。\n    * `readOnly`: **必須**。 マウントを読み取り専用にする必要があるかどうかを決定します。\n  * `registry`\n    **省略可能**。 プライベート コンテナー レジストリの Docker レジストリ資格情報。\n    * `username`: **省略可能**。 レジストリ アカウントのユーザー名。\n    * `password`: **省略可能**。 レジストリ アカウントのパスワード。\n    * `serverUrl`: **省略可能**。 レジストリのURL。\n  * `portMappings`: **省略可能**。 コンテナーにマップする *source:target* ポートのキー値ハッシュ。\n\n#### `prepare_job` の入力の例\n\n```json copy\n{\n  \"command\": \"prepare_job\",\n  \"responseFile\": \"/users/octocat/runner/_work/{guid}.json\",\n  \"state\": {},\n  \"args\": {\n    \"jobContainer\": {\n      \"image\": \"node:18\"\n      \"workingDirectory\": \"/__w/octocat-test2/octocat-test2\",\n      \"createOptions\": \"--cpus 1\",\n      \"environmentVariables\": {\n        \"NODE_ENV\": \"development\"\n      },\n      \"userMountVolumes\": [\n        {\n          \"sourceVolumePath\": \"my_docker_volume\",\n          \"targetVolumePath\": \"/volume_mount\",\n          \"readOnly\": false\n        }\n      ],\n      \"systemMountVolumes\": [\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work\",\n          \"targetVolumePath\": \"/__w\",\n          \"readOnly\": false\n        },\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/externals\",\n          \"targetVolumePath\": \"/__e\",\n          \"readOnly\": true\n        },\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp\",\n          \"targetVolumePath\": \"/__w/_temp\",\n          \"readOnly\": false\n        },\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_actions\",\n          \"targetVolumePath\": \"/__w/_actions\",\n          \"readOnly\": false\n        },\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_tool\",\n          \"targetVolumePath\": \"/__w/_tool\",\n          \"readOnly\": false\n        },\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp/_github_home\",\n          \"targetVolumePath\": \"/github/home\",\n          \"readOnly\": false\n        },\n        {\n          \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp/_github_workflow\",\n          \"targetVolumePath\": \"/github/workflow\",\n          \"readOnly\": false\n        }\n      ],\n      \"registry\": {\n        \"username\": \"octocat\",\n        \"password\": \"examplePassword\",\n        \"serverUrl\": \"https://index.docker.io/v1\"\n      },\n      \"portMappings\": { \"80\": \"801\" }\n    },\n    \"services\": [\n      {\n        \"contextName\": \"redis\",\n        \"image\": \"redis\",\n        \"createOptions\": \"--cpus 1\",\n        \"environmentVariables\": {},\n        \"userMountVolumes\": [],\n        \"portMappings\": { \"80\": \"801\" },\n        \"registry\": {\n          \"username\": \"octocat\",\n          \"password\": \"examplePassword\",\n          \"serverUrl\": \"https://index.docker.io/v1\"\n        }\n      }\n    ]\n  }\n}\n```\n\n#### `prepare_job` の出力の例\n\n次の出力例は、上記の入力で定義されている `responseFile` の内容です。\n\n```json copy\n{\n  \"state\": {\n    \"network\": \"example_network_53269bd575972817b43f7733536b200c\",\n    \"jobContainer\": \"82e8219701fe096a35941d869cf3d71af1d943b5d8bdd718857fb87ac3042480\",\n    \"serviceContainers\": {\n      \"redis\": \"60972d9aa486605e66b0dad4abb678dc3d9116f536579e418176eedb8abb9105\"\n    }\n  },\n  \"context\": {\n    \"container\": {\n      \"id\": \"82e8219701fe096a35941d869cf3d71af1d943b5d8bdd718857fb87ac3042480\",\n      \"network\": \"example_network_53269bd575972817b43f7733536b200c\"\n    },\n    \"services\": {\n      \"redis\": {\n        \"id\": \"60972d9aa486605e66b0dad4abb678dc3d9116f536579e418176eedb8abb9105\",\n        \"ports\": {\n          \"8080\": \"8080\"\n        },\n        \"network\": \"example_network_53269bd575972817b43f7733536b200c\"\n      }\n    },\n    \"isAlpine\": true\n  }\n}\n```\n\n### `cleanup_job`\n\n`cleanup_job` コマンドは、ジョブの最後に呼び出されます。\nGitHub Actions は、 `cleanup_job` コマンドで次のタスクを実行することを前提としています。\n\n* 実行中のサービスまたはジョブ コンテナー (または同等のポッド) を停止します。\n* ネットワークを停止します (存在する場合)。\n* 任意のジョブまたはサービスコンテナー（または同等のポッド）を削除します。\n* ネットワークを削除します (存在する場合)。\n* ジョブのために作成された他のすべてのものをクリーンアップします。\n\n#### `cleanup_job` の引数\n\n`cleanup_job` に引数はありません。\n\n#### `cleanup_job` の入力の例\n\n```json copy\n{\n  \"command\": \"cleanup_job\",\n  \"responseFile\": null,\n  \"state\": {\n    \"network\": \"example_network_53269bd575972817b43f7733536b200c\",\n    \"jobContainer\": \"82e8219701fe096a35941d869cf3d71af1d943b5d8bdd718857fb87ac3042480\",\n    \"serviceContainers\": {\n      \"redis\": \"60972d9aa486605e66b0dad4abb678dc3d9116f536579e418176eedb8abb9105\"\n    }\n  },\n  \"args\": {}\n}\n```\n\n#### `cleanup_job` の出力の例\n\n`cleanup_job` の出力は想定されていません。\n\n### `run_container_step`\n\n`run_container_step` コマンドは、ジョブ内のコンテナー アクションごとに 1 回呼び出されます。\nGitHub Actions は、 `run_container_step` コマンドで次のタスクを実行することを前提としています。\n\n* 必要なコンテナーをプルまたはビルドします (できない場合は失敗します)。\n* コンテナー アクションを実行し、コンテナーの終了コードを返します。\n* ステップ ログ出力を stdout と stderr にストリーミングします。\n* 実行後にコンテナーをクリーンアップします。\n\n#### `run_container_step` の引数\n\n* `image`: **省略可能**。 Docker イメージを含む文字列。 それ以外の場合は、Dockerfile を指定する必要があります。\n* `dockerfile`: **省略可能**。 Dockerfile へのパスを含む文字列。それ以外の場合は、イメージを指定する必要があります。\n* `entryPointArgs`: **省略可能**。 エントリーポイントの引数を含む一覧。\n* `entryPoint`: **省略可能**。 既定のイメージ エントリ ポイントを上書きする必要がある場合に使用するコンテナー エントリ ポイント。\n* `workingDirectory`: **必須**。 作業ディレクトリの絶対パスを含む文字列。\n* `createOptions`: **省略可能**。 YAML で指定された省略可能な \"*create*\" オプション。 詳しくは、「[コンテナ内でのジョブの実行](/ja/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#example-running-a-job-within-a-container)」をご覧ください。\n* `environmentVariables`: **省略可能**。 主要な環境変数のマップを設定します。\n* `prependPath`: **省略可能**。\n  `$PATH` 変数の前に付加する追加のパスの配列。\n* `userMountVolumes`: **省略可能**。 YAML で設定されたユーザー マウント ボリュームの配列。 詳しくは、「[コンテナ内でのジョブの実行](/ja/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#example-running-a-job-within-a-container)」をご覧ください。\n  * `sourceVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのソース パス。\n  * `targetVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのターゲット パス。\n  * `readOnly`: **必須**。 マウントを読み取り専用にする必要があるかどうかを決定します。\n* `systemMountVolumes`: **必須**。 コンテナーにマウントするマウントの配列 (上記と同じフィールドを使用)。\n  * `sourceVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのソース パス。\n  * `targetVolumePath`: **必須**。 Docker コンテナーにマウントされるボリュームへのターゲット パス。\n  * `readOnly`: **必須**。 マウントを読み取り専用にする必要があるかどうかを決定します。\n* `registry`\n  **省略可能**。 プライベート コンテナー レジストリの Docker レジストリ資格情報。\n  * `username`: **省略可能**。 レジストリ アカウントのユーザー名。\n  * `password`: **省略可能**。 レジストリ アカウントのパスワード。\n  * `serverUrl`: **省略可能**。 レジストリのURL。\n* `portMappings`: **省略可能**。 コンテナーにマップする *source:target* ポートのキー値ハッシュ。\n\n#### イメージの入力例\n\nDocker イメージを使用する場合、`\"image\":` パラメーターにイメージ名を指定できます。\n\n```json copy\n{\n  \"command\": \"run_container_step\",\n  \"responseFile\": null,\n  \"state\": {\n    \"network\": \"example_network_53269bd575972817b43f7733536b200c\",\n    \"jobContainer\": \"82e8219701fe096a35941d869cf3d71af1d943b5d8bdd718857fb87ac3042480\",\n    \"serviceContainers\": {\n      \"redis\": \"60972d9aa486605e66b0dad4abb678dc3d9116f536579e418176eedb8abb9105\"\n    }\n  },\n  \"args\": {\n    \"image\": \"node:18\",\n    \"dockerfile\": null,\n    \"entryPointArgs\": [\"-f\", \"/dev/null\"],\n    \"entryPoint\": \"tail\",\n    \"workingDirectory\": \"/__w/octocat-test2/octocat-test2\",\n    \"createOptions\": \"--cpus 1\",\n    \"environmentVariables\": {\n      \"NODE_ENV\": \"development\"\n    },\n    \"prependPath\": [\"/foo/bar\", \"bar/foo\"],\n    \"userMountVolumes\": [\n      {\n        \"sourceVolumePath\": \"my_docker_volume\",\n        \"targetVolumePath\": \"/volume_mount\",\n        \"readOnly\": false\n      }\n    ],\n    \"systemMountVolumes\": [\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work\",\n        \"targetVolumePath\": \"/__w\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/externals\",\n        \"targetVolumePath\": \"/__e\",\n        \"readOnly\": true\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp\",\n        \"targetVolumePath\": \"/__w/_temp\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_actions\",\n        \"targetVolumePath\": \"/__w/_actions\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_tool\",\n        \"targetVolumePath\": \"/__w/_tool\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp/_github_home\",\n        \"targetVolumePath\": \"/github/home\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp/_github_workflow\",\n        \"targetVolumePath\": \"/github/workflow\",\n        \"readOnly\": false\n      }\n    ],\n    \"registry\": null,\n    \"portMappings\": { \"80\": \"801\" }\n  }\n}\n```\n\n#### Dockerfile の入力例\n\nこの例は、コンテナーが Dockerfile によって定義されている場合、`Dockerfile` パラメーターを使用して入力で `\"dockerfile\":` へのパスを指定する方法を示します。\n\n```json copy\n{\n  \"command\": \"run_container_step\",\n  \"responseFile\": null,\n  \"state\": {\n    \"network\": \"example_network_53269bd575972817b43f7733536b200c\",\n    \"jobContainer\": \"82e8219701fe096a35941d869cf3d71af1d943b5d8bdd718857fb87ac3042480\",\n    \"services\": {\n      \"redis\": \"60972d9aa486605e66b0dad4abb678dc3d9116f536579e418176eedb8abb9105\"\n    }\n  },\n  \"args\": {\n    \"image\": null,\n    \"dockerfile\": \"/__w/_actions/foo/dockerfile\",\n    \"entryPointArgs\": [\"hello world\"],\n    \"entryPoint\": \"echo\",\n    \"workingDirectory\": \"/__w/octocat-test2/octocat-test2\",\n    \"createOptions\": \"--cpus 1\",\n    \"environmentVariables\": {\n      \"NODE_ENV\": \"development\"\n    },\n    \"prependPath\": [\"/foo/bar\", \"bar/foo\"],\n    \"userMountVolumes\": [\n      {\n        \"sourceVolumePath\": \"my_docker_volume\",\n        \"targetVolumePath\": \"/volume_mount\",\n        \"readOnly\": false\n      }\n    ],\n    \"systemMountVolumes\": [\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work\",\n        \"targetVolumePath\": \"/__w\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/externals\",\n        \"targetVolumePath\": \"/__e\",\n        \"readOnly\": true\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp\",\n        \"targetVolumePath\": \"/__w/_temp\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_actions\",\n        \"targetVolumePath\": \"/__w/_actions\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_tool\",\n        \"targetVolumePath\": \"/__w/_tool\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp/_github_home\",\n        \"targetVolumePath\": \"/github/home\",\n        \"readOnly\": false\n      },\n      {\n        \"sourceVolumePath\": \"/home/octocat/git/runner/_layout/_work/_temp/_github_workflow\",\n        \"targetVolumePath\": \"/github/workflow\",\n        \"readOnly\": false\n      }\n    ],\n    \"registry\": null,\n    \"portMappings\": { \"80\": \"801\" }\n  }\n}\n```\n\n#### `run_container_step` の出力の例\n\n`run_container_step` の出力は想定されていません。\n\n### `run_script_step`\n\nGitHub Actions は、次のタスクを実行することを前提としています。\n\n* ジョブ コンテナー内で指定されたスクリプトを呼び出して、終了コードを返します。\n* ステップ ログ出力を stdout と stderr にストリーミングします。\n\n#### `run_script_step` の引数\n\n* `entryPointArgs`: **省略可能**。 エントリポイントの引数を含むリスト。\n* `entryPoint`: **省略可能**。 既定のイメージ エントリ ポイントを上書きする必要がある場合に使用するコンテナー エントリ ポイント。\n* `prependPath`: **省略可能**。\n  `$PATH` 変数の前に付加する追加のパスの配列。\n* `workingDirectory`: **必須**。 作業ディレクトリの絶対パスを含む文字列。\n* `environmentVariables`: **省略可能**。 主要な環境変数のマップを設定します。\n\n#### `run_script_step` の入力の例\n\n```json copy\n{\n  \"command\": \"run_script_step\",\n  \"responseFile\": null,\n  \"state\": {\n    \"network\": \"example_network_53269bd575972817b43f7733536b200c\",\n    \"jobContainer\": \"82e8219701fe096a35941d869cf3d71af1d943b5d8bdd718857fb87ac3042480\",\n    \"serviceContainers\": {\n      \"redis\": \"60972d9aa486605e66b0dad4abb678dc3d9116f536579e418176eedb8abb9105\"\n    }\n  },\n  \"args\": {\n    \"entryPointArgs\": [\"-e\", \"/runner/temp/example.sh\"],\n    \"entryPoint\": \"bash\",\n    \"environmentVariables\": {\n      \"NODE_ENV\": \"development\"\n    },\n    \"prependPath\": [\"/foo/bar\", \"bar/foo\"],\n    \"workingDirectory\": \"/__w/octocat-test2/octocat-test2\"\n  }\n}\n```\n\n#### `run_script_step` の出力の例\n\n`run_script_step` の出力は想定されていません。\n\n## カスタマイズ スクリプトの生成\n\nGitHub では、Docker と Kubernetes のカスタマイズ スクリプトを生成する方法を示すサンプル リポジトリが作成されています。\n\n> \\[!NOTE]\n> 生成されたスクリプトはテスト用として使用できますが、自身の要件に適しているかどうかを確認する必要があります。\n\n1. [actions/runner-container-hooks](https://github.com/actions/runner-container-hooks) リポジトリをセルフホステッド ランナーに複製します。\n\n2. `examples/` ディレクトリには、いくつかの既存のカスタマイズ コマンドがそれぞれ独自の JSON ファイルに含まれています。 これらの例を確認し、独自のカスタマイズ コマンドの開始点として使用できます。\n\n   * `prepare_job.json`\n   * `run_script_step.json`\n   * `run_container_step.json`\n\n3. npm パッケージをビルドします。 これらのコマンドは、`index.js` および `packages/docker/dist` 内に `packages/k8s/dist` ファイルを生成します。\n\n   ```shell\n   npm install && npm run bootstrap && npm run build-all\n   ```\n\n結果の `index.js` が GitHub Actionsによってトリガーされると、JSON ファイルで定義されたカスタマイズ コマンドが実行されます。\n`index.js` をトリガーするには、次のセクションで説明するように、`ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER` 環境変数に追加する必要があります。\n\n## カスタマイズ スクリプトを起動する\n\nカスタム スクリプトはランナー上に配置する必要があります。ただし、セルフホステッド ランナー アプリケーション ディレクトリ(つまり、ランナーソフトウェアをダウンロードして解凍したディレク トリ)には格納しないでください。 スクリプトは、ランナー サービスを実行しているサービス アカウントのセキュリティ コンテキストで実行されます。\n\n> \\[!NOTE]\n> トリガーされたスクリプトは同期的に処理されるので、実行中はジョブの実行が禁止されます。\n\nスクリプトへの絶対パスを含む次の環境変数がランナーに含まれている場合、スクリプトは自動実行されます。\n\n* `ACTIONS_RUNNER_CONTAINER_HOOKS`: この環境変数に定義されているスクリプトは、ジョブがランナーに割り当てられ、ジョブの実行が開始される前に開始されます。\n\nこれらの環境変数を設定するには、それをオペレーティング システムに追加するか、セルフホステッド ランナー アプリケーション ディレクトリ内の `.env` という名前のファイルに追加します。 たとえば、次の `.env` エントリがあると、コンテナーベースの各ジョブが実行される前に、`/Users/octocat/runner/index.js` にあるスクリプトがランナーによって自動実行されます。\n\n```bash\nACTIONS_RUNNER_CONTAINER_HOOKS=/Users/octocat/runner/index.js\n```\n\nジョブが常にコンテナー内で実行され、その後常にコンテナーのカスタマイズが適用されるようにする場合、セルフホステッド ランナーの `ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER` 変数を `true` に設定できます。 これにより、ジョブ コンテナーを指定しないジョブは失敗します。\n\n## トラブルシューティング\n\n### タイムアウトなしの設定\n\n現在、`ACTIONS_RUNNER_CONTAINER_HOOKS` によって実行されるスクリプトに使用できるタイムアウト設定はありません。 そのため、スクリプトにタイムアウト処理を追加することを検討できます。\n\n### ワークフロー実行ログの確認\n\nスクリプトが実行中かどうかを確認するために、そのジョブのログを確認することができます。 ログの確認の詳細については、「[ワークフロー実行ログの使用](/ja/enterprise-cloud@latest/actions/how-tos/monitor-workflows/use-workflow-run-logs#viewing-logs-to-diagnose-failures)」を参照してください。"}