GitHub Actions の concurrency group とは?
concurrency group はキーごとに 1 つの実行だけをアクティブに保ち、残りをキャンセルまたはキューに入れます。
急速な push や繰り返しの deploy は重複する実行を積み重ねる可能性があります。concurrency キーは実行を共有名の下にグループ化し、GitHub が 1 つだけを進行中に保つようにして、競合と浪費される分を防ぎます。
それは何か
concurrency.group 式で識別される論理グループです。GitHub はグループごとに一度に 1 つの実行中または保留中の実行だけを許可します。
A concurrency group
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: trueどう動くか
新しい実行が、すでに進行中の実行を持つグループに入ると、GitHub は新しい実行をキューに入れるか、cancel-in-progress: true であれば古い実行をキャンセルして新しいものを開始します。
一般的なパターン
- 新しいコミットが来たら古い PR ビルドをキャンセルする。
- environment や branch ごとに deploy をシリアライズする。
- 2 つのリリースが同じ ref で競合しないようにする。
なぜ重要か
concurrency の制御は競合する deploy を防ぎ、古くなった CI 実行をキャンセルすることでランナーの分を節約します。小さなブロックですが、信頼性とコストの面で大きな利点があります。
関連する概念
concurrency group はキーを構築するのに式とコンテキストを使い、deployment と environment を補完します。
重要なポイント
- concurrency group はキーごとに 1 つのアクティブな実行を保ちます。
cancel-in-progress: trueは古い実行を終了させます。- deploy の競合を防ぎ、分を節約します。
関連ガイド
What Is an Expression in GitHub Actions?An expression in GitHub Actions is logic inside ${{ }} that evaluates contexts, functions, and operators to c…
What Is a Context in GitHub Actions?A context in GitHub Actions is a structured object of run data, like github, env, and secrets, that you read…
What Is a Deployment in GitHub Actions?A deployment in GitHub Actions is a tracked release to an environment, recording status and history so you ca…
What Is a Workflow Run in GitHub Actions?A workflow run is a single execution of a workflow triggered by an event, with its own logs, status, and a un…