動機

因為另一個project的需求 需要CI可以透過web api來rebuild,所以就換到github action了

repository_dispatch

可以自訂type,就可以透過curl去打API

在yaml中放repository_dispatch

on:
  repository_dispatch:
    types: rebuild

這樣就可以用curl讓github action啟動

curl -H "Accept: application/vnd.github.v3+json" \
             -H "Authorization: token $MY_SECRET" \
             --request POST \
             --data '{"event_type": "rebuild"}' \
             https://api.github.com/repos/name/repo/dispatches

如果要帶env

    - env:
        MY_SECRET: ${{ secrets.PERSONAL_TOKEN }}
      run: |
        curl -H "Accept: application/vnd.github.v3+json" \
             -H "Authorization: token $MY_SECRET" \
             --request POST \
             --data '{"event_type": "rebuild"}' \
             https://api.github.com/repos/name/repo/dispatches