7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitHub ActionsのWorkflow実行順序制御

Posted at

GitHub Actionsで複数ジョブを実行する時デフォルトでは並列に実行されますが、順序を制御したい場合はneedsを定義します。

jobs:
  a:
    ...

  b:
    needs: a # aが終了後に実行される
    ...

で、1つのファイルに定義が増えすぎたりしてファイルを分けた場合は他ファイルのworkflowをimportすることができます。
呼ばれる側はworkflow_callを定義しておきます。

# 呼ばれる側のファイル
on:
  workflow_call:
jobs:
  a:
    ...

# 呼ぶ側のファイル
jobs:
  a:
    uses: ./.github/workflows/[呼ばれる側のファイル名]

  b:
    needs: a
      ...

ちなみに呼ばれる側のファイルはworkflow_call以外にも通常の動作条件(PR作成時とかpush時とか)が指定できます。

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?