GitHub Actions の job とは?
job は workflow における作業の単位です。1 つの runner 上で実行され、順序付けられた step のリストを含みます。
workflow は job で構成されます。各 job は新しい runner を受け取り、その step を順番に実行し、独自の成否を報告します。job を理解することは、並列性と依存関係を制御する鍵です。
何であるか
job は workflow の jobs: キーの下にある名前付きのエントリです。runs-on: でどこで実行するかを指定し、steps: のリストで何をするかを指定します。
A single job
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm test仕組み
各 job は独自の新しい仮想マシン上で実行されます。job 内の step はそのマシンの filesystem と環境を共有しますが、異なる job は互いに分離されています。
デフォルトで並列
workflow に複数の job があるとき、needs: で依存関係を宣言しない限り、それらは並列に実行されます。これにより workflow は高速になりますが、job は共有された状態を前提にできないことを意味します。
なぜ重要か
作業を job に分割することで、並列化し、テストの後に deploy をゲートし、異なる step を異なるオペレーティングシステムで実行できます。各 job は課金と並列性の単位でもあります。
関連する概念
job は step を含み、runner 上で実行され、needs: キーワードで順序付けて依存関係グラフを形成できます。
重要なポイント
- job は単一の新しい runner 上で実行されます。
- job は
needs:で順序付けない限り並列に実行されます。 - job 内の step は filesystem を共有しますが、別々の job は共有しません。
関連ガイド
What Is a Step in GitHub Actions?A step in GitHub Actions is a single task in a job. It either runs a shell command with run or invokes a reus…
What Is a GitHub Actions Runner?A runner is the machine that executes a GitHub Actions job. It can be GitHub-hosted, self-hosted, or a manage…
What Is the needs Keyword in GitHub Actions?The needs keyword makes one job wait for another to finish, creating a dependency graph and giving access to…
What Is a GitHub Actions Workflow File?A GitHub Actions workflow is a YAML file in .github/workflows that defines which events trigger automation an…