From d4690afc01f939f0904ad36ad4c5674040f1f59a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 05:45:21 +0100 Subject: [PATCH] [BUGFIX] Don't create multiple whitespace Prs (#1496) Co-authored-by: lina.wolf --- .github/workflows/apply-precommit.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apply-precommit.yml b/.github/workflows/apply-precommit.yml index 44019f6f..831486e7 100644 --- a/.github/workflows/apply-precommit.yml +++ b/.github/workflows/apply-precommit.yml @@ -32,8 +32,19 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create and push changes if needed + - name: Check for existing PR if: env.FIX_NEEDED == 'true' + id: check_pr + run: | + EXISTING_PR=$(gh pr list --state open --search "Fix whitespace issues" --json number -q '.[].number') + if [[ -n "$EXISTING_PR" ]]; then + echo "EXISTING_PR=true" >> $GITHUB_ENV + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push changes if needed + if: env.FIX_NEEDED == 'true' && env.EXISTING_PR != 'true' id: create_branch run: | git config user.name "github-actions[bot]" @@ -49,7 +60,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Open Pull Request - if: env.FIX_NEEDED == 'true' + if: env.FIX_NEEDED == 'true' && env.EXISTING_PR != 'true' uses: repo-sync/pull-request@v2 with: source_branch: ${{ env.branch_name }}