Skip to content

Commit 3591e7f

Browse files
committed
check for approval and approve
1 parent 32fcdfc commit 3591e7f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.github/workflows/auto_approve.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@ name: "Auto Approve Workflow Runs"
22

33
on: pull_request
44

5+
permissions:
6+
actions: "write"
7+
58
jobs:
69
auto-approve-workflow:
710
runs-on: ubuntu-latest
811
steps:
912
- name: Checkout
1013
uses: actions/checkout@v4
1114

12-
- name: "Print comments"
15+
- name: Approve workflow run
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1318
run: |
14-
echo "comments: ${{ github.event.pull_request.comments }}"
19+
set +e
20+
21+
comments=$(gh pr view --json comments)
22+
23+
# The enum values are explained here:
24+
# https://docs.github.com/en/graphql/reference/enums#commentauthorassociation
25+
expr='
26+
.comments
27+
| map(select(.authorAssociation | IN("COLLABORATOR", "MEMBER", "OWNER")))
28+
| any(.body | contains("@rerun-bot approve"))
29+
'
30+
31+
if [ $(echo "$comments" | jq "$expr") = "true" ]; then
32+
echo "can approve run_id:${{ github.run_id }}"
33+
fi
1534

0 commit comments

Comments
 (0)