GitHub Actions で特定のラベルで発火

下記のような if 条件を書けばいける。 some-defined-label が付与されていると発火。

if: contains(github.event.pull_request.labels.*.name, 'some-defined-label')

Do something if a particular label is set - Code to Cloud / GitHub Actions - GitHub Community

contains とは?

contains( search, item )

searchがitem を含む場合、true を返します。 searchが配列の場合、itemが配列の要素であれば、この関数はtrueを返します。 searchが文字列の場合、itemがsearchの部分文字列であれば、この関数はtrueを返します。

https://docs.github.com/ja/actions/learn-github-actions/expressions#contains

GitHub Actions で gh コマンドでアサイン

gh コマンドはデフォルトで使えるようになっているようなので、環境変数で token や repo, pr number などを渡してやるといい感じに動く。

jobs:
  assign:
    runs-on: ubuntu-20.04
    timeout-minutes: 1

    steps:
      - run: cat $GITHUB_EVENT_PATH
      - run: gh pr edit $NUMBER --add-assignee $ASSIGNEE
        env:
          GH_TOKEN: ${{ github.token }}
          GH_REPO: ${{ github.repository }}
          NUMBER: ${{ github.event.pull_request.number }}
          ASSIGNEE: ${{ github.event.pull_request.user.login }}
        if: ${{ toJSON(github.event.pull_request.assignees) == '[]' }}

PR の assignees が空だったときに自動アサイン