LoginSignup
1
5

More than 3 years have passed since last update.

あるワークフローから他のワークフローを実行する方法

Last updated at Posted at 2021-01-01

はじめに

GITHUB のエンドポイントに POST するやり方もあるかと actions 使った方が見通しがいいので actions を使った説明をします。(備忘録がメイン)

今回、こちらの actions を使います。

やりたいこと

dispatcher.yml を実行したら dispatched.yml を実行すること。

コード

.github/workflows
├── dispatched.yml
└── dispatcher.yml
dispatcher.yml
name: Dispatcher
on: [workflow_dispatch]


jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
    - name: Invoke workflow
      uses: benc-uk/workflow-dispatch@v1
      with:
        workflow: Dispatched
        token: ${{ secrets.TOKEN }}
        inputs: '{ "message": "blah blah", "debug": "true" }'
dispatched.yml
name: Dispatched
on:
  workflow_dispatch:
    inputs:
      message:
        default: 'test'
      debug:
        default: 'false'

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
    - name: Tests
      run:
        echo ${{ github.event.inputs.message }}
        echo ${{ github.event.inputs.debug }}

実装の解説

書く必要ないかもしれないが・・・・

  • dispatched.yml のワークフローに name という蘭に名前を設定
  • キャッチしたいパラメータも記述
  • dispatcher.yml の Invoke workflow で実行したいワークフローの名前を指定
  • 入力したいパラメータを入力

まとめ

今回、同一レポジトリにおいて他のワークフローを実行する方法を紹介しました。
他のレポジトリのワークフローも実行することが可能です。
必要であればぜひ使ってください。

1
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
1
5