Help us understand the problem. What is going on with this article?

GitHubActionsのrepository_dispatchを試す

概要

GitHubActionsではGitHub上のいろんなイベントをフックしてActionを実行できますが、外部からAPIリクエストによってもActionを起動することができます。それがrepository_dispatchです。

GitHubActionsのイベントフックにrepository_dispatchを設定する

workflow.yaml
name: Sample

on: repository_dispatch

・・・以下省略・・・

GitHubのAPIを叩く

curl -X POST -H "Authorization: token トークン" -H "Accept: application/vnd.github.everest-preview+json" -d '{"event_type": "イベントタイプ(自分で決める)"}' -i  https://api.github.com/repos/オーガナイゼーション名/リポジトリ名/dispatches

詳しくはこちら: https://developer.github.com/v3/repos/#create-a-repository-dispatch-event

トークンはGitHubでSettings > Developer settings > Personal access tokensで作成できます。作成するときにはrepoスコープについての権限を付与することを忘れないでください。

repository_dispatch経由で実行されるActionのブランチはどうやって指定するの?

残念ながらできないようです。https://help.github.com/en/articles/events-that-trigger-workflows#external-events-repository_dispatch に書いてあるとおり、Commit that changes statusなので、一番最新で変更があったブランチの最新のCommitで自動的にActionが走ると思われます。これだと使えない…。repository_dispatchはまだお試しくらいの機能なようです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした