add reviewbot

This commit is contained in:
Ludy87 2025-06-24 08:57:22 +02:00
parent 8e8f0492c4
commit 6e72d9075a
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
2 changed files with 66 additions and 0 deletions

View File

@ -8,5 +8,8 @@
"reecebrowne",
"DarioGii",
"ConnorYoh"
],
"repo_devs_reviewers": [
"Frooodle"
]
}

63
.github/workflows/reviewbot.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: ReviewBot Approver
on:
issue_comment:
types: [created]
permissions:
contents: read
jobs:
approve-pr:
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, 'approvebot')
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup GitHub App Bot
if: github.actor != 'dependabot[bot]'
id: setup-bot
uses: ./.github/actions/setup-bot
continue-on-error: true
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Check if actor is repo developer
id: actor
run: |
if [[ "${{ github.actor }}" == *"[bot]" ]]; then
echo "PR opened by a bot skipping AI title review."
echo "is_repo_dev=false" >> $GITHUB_OUTPUT
exit 0
fi
if [ ! -f .github/config/repo_devs.json ]; then
echo "Error: .github/config/repo_devs.json not found" >&2
exit 1
fi
# Validate JSON and extract repo_devs
REPO_DEVS=$(jq -r '.repo_devs_reviewers[]' .github/config/repo_devs.json 2>/dev/null || { echo "Error: Invalid JSON in repo_devs.json" >&2; exit 1; })
# Convert developer list into Bash array
mapfile -t DEVS_ARRAY <<< "$REPO_DEVS"
if [[ " ${DEVS_ARRAY[*]} " == *" ${{ github.actor }} "* ]]; then
echo "is_repo_dev=true" >> $GITHUB_OUTPUT
else
echo "is_repo_dev=false" >> $GITHUB_OUTPUT
fi
- name: Approve the Pull Request
if: steps.actor.outputs.is_repo_dev == 'true'
env:
GITHUB_TOKEN: ${{ steps.setup-bot.outputs.token }}
run: |
gh pr review ${{ github.event.issue.number }} --approve -b ":robot: *${{ steps.setup-bot.outputs.app-slug }}* approved this PR in response to a comment from @${{ github.actor }}."