本記事でできること
PR(プルリクエスト)を作成した際に、PRを作成したユーザーを自動的に Assignees に追加する。
コード
.github/workflows/auto-assign-pr-creator.yaml を作成する
name: PR automation
on:
pull_request:
types: opened
permissions:
pull-requests: write
repository-projects: read
jobs:
assign:
name: PR automation
# 実行が10分を超えるとタイムアウトするように設定する
timeout-minutes: 10
# ジョブが実行される環境は、環境に合わせて設定する
runs-on: ubuntu-22.04
# コミットが重なった時同時に実行されないように、進行中のジョブをキャンセルするように設定する。
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# PR作成者をアサインに追加する。
steps:
- name: Set GitHub assignees
env:
GH_TOKEN: ${{ github.token }}
run: gh pr edit ${{ github.event.number }} --add-assignee ${{ github.actor }} --repo ${{ github.repository }}
感想
毎回 Assignees を設定するの地味にめんどくさかった。。
無事自動化できてストレス減りました
ps. 初めて GitHubActions 使用してみたが、便利すぎる!!