githubでプルリクエストを作った人を自動でassigneesにする
はじめに
こんにちは。webエンジニア社会人をしている ningenMe です。
タイトル通り、assignees設定を自動化します。
下記のことを行います。
- プルリクエストを作った人を自動で assigneesにする
- github actionsで処理を行う
- yamlではパースなどを自分で書かずに、GitHub Actions公式 のものを使う
GitHub
実際に動くソースはこちら
name: assignees-sample
on:
  pull_request:
    branches: [ main ]
jobs:
  assignees:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: actions/github-script@v4.1.0
        if: github.event_name == 'pull_request'
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            github.issues.addAssignees({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              assignees: `${{ github.actor }}`
            });
UI上でどうなるか
PRの右側らへんを見るとassigneesが付いているのがわかります。

説明
説明と言うほど説明することはないです。
actions/github-script という便利なものがあるのでそれを活用します。
バージョンは 2021/09/14 時点での最新のものを記載しています。
実際に使う場合は https://github.com/actions/github-script/tags で最新を確認すると良いと思います。
先行研究
一応上記とはやり方が別になっていると思います。大した処理ではないのでなんでも良い気はします。
さいごに
超ライトな記事でした。
ではでは。

