Skip to content

Commit 9b0cb84

Browse files
authored
don't let vouch auto-close a pr re-opened by a maintainer. (#880)
1 parent a5cd0f7 commit 9b0cb84

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

.github/workflows/vouch-check-pr.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,25 @@ jobs:
1212
name: Check PR author
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: mitchellh/vouch/action/check-pr@c6d80ead49839655b61b422700b7a3bc9d0804a9 # v1.4.2
15+
- name: Check if reopened by a maintainer
16+
id: maintainer
17+
if: github.event.action == 'reopened'
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
ACTOR: ${{ github.actor }}
21+
REPO: ${{ github.repository }}
22+
run: |
23+
PERMISSION=$(gh api "repos/$REPO/collaborators/$ACTOR/permission" --jq '.permission' 2>/dev/null || echo "none")
24+
echo "Actor $ACTOR has permission: $PERMISSION"
25+
if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "maintain" || "$PERMISSION" == "write" ]]; then
26+
echo "is_maintainer=true" >> "$GITHUB_OUTPUT"
27+
else
28+
echo "is_maintainer=false" >> "$GITHUB_OUTPUT"
29+
fi
30+
31+
- name: Vouch check
32+
if: github.event.action == 'opened' || steps.maintainer.outputs.is_maintainer != 'true'
33+
uses: mitchellh/vouch/action/check-pr@c6d80ead49839655b61b422700b7a3bc9d0804a9 # v1.4.2
1634
with:
1735
pr-number: ${{ github.event.pull_request.number }}
1836
auto-close: true

0 commit comments

Comments
 (0)