From fc539899467509f5ae0a37c6fc430b28ac133c36 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 19 Apr 2024 10:47:00 -0400 Subject: [PATCH] Create pr-check.yml For users with many open PRs, creates a warning message in the PR description when opening a new PR, encouraging users to complete existing PRs before opening new ones. --- .github/workflows/pr-check.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/pr-check.yml diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 000000000..951fd02c1 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,26 @@ +name: PR Check + +on: + pull_request: + types: + - opened + +jobs: + check-pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get PR count + id: pr-count + run: | + PR_COUNT=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/naturalcrit/homebrewery/pulls? state=open&head=${{ github.actor }}:${{ github.head_ref }}" | jq '. | length') + echo "::set-output name=pr_count::$PR_COUNT" + + - name: Update PR description + if: ${{ steps.pr_count.outputs.pr_count }} -ge 1 + run: | + gh pr edit ${{ github.event.number }} --body "You already have ${{ steps.pr-count.outputs.pr_count }} PRs open. Consider completing some of your existing PRs before opening new ones."