LoginSignup
1
1

More than 1 year has passed since last update.

githubでプルリクエストを作った人を自動でassigneesにする

Posted at

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上でどうなるか

botがassignしてくれます
image.png

PRの右側らへんを見るとassigneesが付いているのがわかります。
image.png

説明

説明と言うほど説明することはないです。

actions/github-script という便利なものがあるのでそれを活用します。
バージョンは 2021/09/14 時点での最新のものを記載しています。

実際に使う場合は https://github.com/actions/github-script/tags で最新を確認すると良いと思います。

先行研究

一応上記とはやり方が別になっていると思います。大した処理ではないのでなんでも良い気はします。

さいごに

超ライトな記事でした。

ではでは。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1