Skip to content

Automatically Assign PR Author if No Assignee is Set #2

Automatically Assign PR Author if No Assignee is Set

Automatically Assign PR Author if No Assignee is Set #2

name: Auto Assign PR Author
on:
pull_request:
types: [opened, reopened]
permissions:
contents: read
pull-requests: write
jobs:
auto-assign:
runs-on: ubuntu-latest
steps:
- name: Check If Assignee Exists
uses: actions/github-script@v6
id: check-assignee
with:
script: |
const assignees = context.payload.pull_request.assignees;
return assignees.length > 0;
- name: Assign PR Author If No Assignee
if: steps.check-assignee.outputs.result == 'false'
uses: actions-ecosystem/action-add-assignees@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
assignees: ${{ github.event.pull_request.user.login }}