From ed01697e110fbaac686d5814004da5f66eeff100 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 29 Jan 2025 12:59:04 +0100 Subject: [PATCH] Setup review-ready label synchronization Committed via https://github.com/asottile/all-repos --- .github/workflows/review-label.yml | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/review-label.yml diff --git a/.github/workflows/review-label.yml b/.github/workflows/review-label.yml new file mode 100644 index 00000000..b74cac4f --- /dev/null +++ b/.github/workflows/review-label.yml @@ -0,0 +1,45 @@ +name: Sync review-ready label + +on: + pull_request: + branches: [master] + types: + - labeled + - unlabeled + - opened + - edited + - closed + - reopened + - synchronize + - converted_to_draft + - ready_for_review + - review_requested + - review_request_removed + - auto_merge_enabled + - auto_merge_disabled + + +jobs: + label: + name: Sync review label + runs-on: ubuntu-latest + if: github.actor != 'dependabot[bot]' + timeout-minutes: 5 + env: + GH_TOKEN: ${{ github.token }} + steps: + - name: Ensure label exists + run: | + gh label create review-ready --color B2D89F --description "PR is ready for the review" --repo ${{ github.repository }} || true + - name: Sync label + run: | + ISDRAFT1=$(gh pr view ${{ github.event.pull_request.number }} --json isDraft --jq '.isDraft' --repo ${{ github.repository }}) + ISDRAFT="$(echo -e "${ISDRAFT1}" | tr -d '[:space:]')" + echo "isdraft=$ISDRAFT" + if [[ "false" == "$ISDRAFT" ]]; then + echo "Set label" + gh pr edit ${{ github.event.pull_request.number }} --add-label review-ready --repo ${{ github.repository }} + else + echo "Remove label" + gh pr edit ${{ github.event.pull_request.number }} --remove-label review-ready --repo ${{ github.repository }} + fi