Skip to content

Assign pr

Assign pr #5

name: Assign PR to Code Owner
on:
pull_request:
types: [opened, reopened]
jobs:
assign_pr:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Get Code Owners
run: |
CODEOWNERS_FILE=.github/CODEOWNERS
if [ -f "$CODEOWNERS_FILE" ]; then
CODE_OWNER=$(grep -v '^#' $CODEOWNERS_FILE | grep -Eo '@[a-zA-Z0-9_-]+' | head -n 1)
echo "::set-output name=code_owner::${CODE_OWNER#@}"
else
echo "No CODEOWNERS file found."
exit 1
fi
- name: Assign PR to Code Owner
if: ${{ steps.get-code-owners.outputs.code_owner }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-assignee ${{ steps.get-code-owners.outputs.code_owner }} --repo ${{ github.repository }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}