forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 144
45 lines (37 loc) · 1.63 KB
/
auto_pr_review.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: "PR Review"
on:
pull_request_target:
types: [opened, reopened]
jobs:
pr_check:
name: Check PR Target Branch
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Target Branch
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
TOKEN_USERNAME=$(gh api user -H "Authorization: token $GITHUB_TOKEN" --jq '.login')
if [[ "${{ github.actor }}" == "FrogAi" ]]; then
echo "PR opened or reopened by FrogAi. No action needed."
exit 0
fi
if [[ "${{ github.base_ref }}" != "MAKE-PRS-HERE" ]]; then
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-H "Authorization: token $GITHUB_TOKEN" \
-f body="Please submit your pull request to the \"MAKE-PRS-HERE\" branch."
gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \
-X PATCH -H "Authorization: token $GITHUB_TOKEN" -f state='closed'
exit 1
else
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-H "Authorization: token $GITHUB_TOKEN" \
-f body="Thank you for your PR! If you're not already in the FrogPilot Discord, [feel free to join](https://discord.FrogPilot.download) and let me know you've opened a PR!"
fi