概要
注釈: ジョブレベルで並行処理が指定されている場合、ジョブの順序は保証されないか、互いに 5 分以内にそのキューを実行します。
You can use jobs.<job_id>.concurrency
to ensure that only a single job or workflow using the same concurrency group will run at a time. 並行処理グループには、任意の文字列または式を使用できます。 式は、secrets
コンテキストを除く任意のコンテキストを使用できます。 For more information about expressions, see "Expressions."
ワークフローレベルで concurrency
を指定することもできます。 詳しい情報については、concurrency
を参照してください。
並行ジョブもしくはワークフローがキューに入っている場合、リポジトリ内の同じ並行グループを使う他のジョブもしくはワークフローが進行中だと、キューイングされたジョブもしくはワークフローは保留中
になります。 この並行グループ内の以前の保留中のジョブもしくはワークフローは、キャンセルされます。 同じ並行グループ内にある実行中のジョブもしくはワークフローもキャンセルするには、cancel-in-progress: true
を指定してください。
並行性とデフォルトの動作の使用例
concurrency: staging_environment
concurrency: ci-${{ github.ref }}
並行性を使って進行中のジョブもしくは実行をキャンセルする例
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
Example: Using a fallback value
If you build the group name with a property that is only defined for specific events, you can use a fallback value. For example, github.head_ref
is only defined on pull_request
events. If your workflow responds to other events in addition to pull_request
events, you will need to provide a fallback to avoid a syntax error. The following concurrency group cancels in-progress jobs or runs on pull_request
events only; if github.head_ref
is undefined, the concurrency group will fallback to the run ID, which is guaranteed to be both unique and defined for the run.
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Example: Only cancel in-progress jobs or runs for the current workflow
If you have multiple workflows in the same repository, concurrency group names must be unique across workflows to avoid canceling in-progress jobs or runs from other workflows. Otherwise, any previously in-progress or pending job will be canceled, regardless of the workflow.
To only cancel in-progress runs of the same workflow, you can use the github.workflow
property to build the concurrency group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true