Skip to content

Workflow file for this run

name: Auto-approve PRs from Administrators
on:
pull_request:
types: [opened]
jobs:
auto_approve:
runs-on: ubuntu-latest
steps:
- name: Check if author is administrator
run: |
AUTHOR_LOGIN=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
if [[ $(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/collaborators/$AUTHOR_LOGIN/permission" | jq -r '.permission') == "admin" ]]; then
echo "::set-output name=approve::true"
else
echo "::set-output name=approve::false"
fi
id: check_admin
- name: Auto-approve if author is admin
if: steps.check_admin.outputs.approve == 'true'
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
event: 'APPROVE'
})