Skip to content

Commit 84ba66f

Browse files
authored
Setup review-ready label synchronization (#332)
Committed via https://github.com/asottile/all-repos
1 parent 725cce1 commit 84ba66f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/review-label.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Sync review-ready label
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
types:
7+
- labeled
8+
- unlabeled
9+
- opened
10+
- edited
11+
- closed
12+
- reopened
13+
- synchronize
14+
- converted_to_draft
15+
- ready_for_review
16+
- review_requested
17+
- review_request_removed
18+
- auto_merge_enabled
19+
- auto_merge_disabled
20+
21+
22+
jobs:
23+
label:
24+
name: Sync review label
25+
runs-on: ubuntu-latest
26+
if: github.actor != 'dependabot[bot]'
27+
timeout-minutes: 5
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
steps:
31+
- name: Ensure label exists
32+
run: |
33+
gh label create review-ready --color B2D89F --description "PR is ready for the review" --repo ${{ github.repository }} || true
34+
- name: Sync label
35+
run: |
36+
ISDRAFT1=$(gh pr view ${{ github.event.pull_request.number }} --json isDraft --jq '.isDraft' --repo ${{ github.repository }})
37+
ISDRAFT="$(echo -e "${ISDRAFT1}" | tr -d '[:space:]')"
38+
echo "isdraft=$ISDRAFT"
39+
if [[ "false" == "$ISDRAFT" ]]; then
40+
echo "Set label"
41+
gh pr edit ${{ github.event.pull_request.number }} --add-label review-ready --repo ${{ github.repository }}
42+
else
43+
echo "Remove label"
44+
gh pr edit ${{ github.event.pull_request.number }} --remove-label review-ready --repo ${{ github.repository }}
45+
fi

0 commit comments

Comments
 (0)