毎回のプルリク後に Assignees を手動でポチポチ設定するのが若干の手間だと感じていたところ、素晴らしい記事に巡り合いました。
- github でプルリクエストを作った人を自動で assignees にする - Qiita
- https://qiita.com/ningenMe/items/416b3f9e593151360d58
現在は、上記の記事から actions/github-script の最新バージョンが上がっていたり(本記事時点での最新は v6)、そのほか微調整を加えたのが以下です。
assignees.yaml
name: "Assign"
on:
  pull_request:
    types: [opened]
jobs:
  Assignees:
    if: ${{ github.actor != 'dependabot[bot]' }}
    runs-on: ubuntu-latest
    timeout-minutes: 1
    steps:
      - uses: actions/checkout@master
      - uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            github.rest.issues.addAssignees({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              assignees: `${{ github.actor }}`
            });
よければ使ってみてくださいませ。
なお補足ですが、以下の条件判定を行うことで Dependabot によって行われたプルリクエストのときは後続の処理を行わないようにしています。
if: ${{ github.actor != 'dependabot[bot]' }}
Dependabot を Assignees に割り当てることはできませんが、そのせいで後続の処理がエラーとなり、このワークフローが Fail してしまうのを防ぐためです。
Dependabot を使用していない場合はこの1行を削除いただいても構いませんし、残しておいても問題ありません。
その他参考 #
actions/github-script #
https://github.com/actions/github-script
githubA pre-authenticated octokit/rest.js client with pagination plugins
contextAn object containing the context of the workflow run- …
octokit/rest.js #
https://octokit.github.io/rest.js
Add assignees to an issue
octokit.rest.issues.addAssignees({
  owner, // required
  repo, // required
  issue_number, // required
  assignees, // optional
});