Skip to content

Commit 2d9c6bc

Browse files
authored
[BUGFIX] Create whitespace fixexs once (#654)
1 parent b7da4d2 commit 2d9c6bc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

.github/workflows/apply-precommit.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,19 @@ jobs:
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434

35-
- name: Create and push changes if needed
35+
- name: Check for existing PR
3636
if: env.FIX_NEEDED == 'true'
37+
id: check_pr
38+
run: |
39+
EXISTING_PR=$(gh pr list --state open --search "Fix whitespace issues" --json number -q '.[].number')
40+
if [[ -n "$EXISTING_PR" ]]; then
41+
echo "EXISTING_PR=true" >> $GITHUB_ENV
42+
fi
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Create and push changes if needed
47+
if: env.FIX_NEEDED == 'true' && env.EXISTING_PR != 'true'
3748
id: create_branch
3849
run: |
3950
git config user.name "github-actions[bot]"
@@ -49,7 +60,7 @@ jobs:
4960
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5061

5162
- name: Open Pull Request
52-
if: env.FIX_NEEDED == 'true'
63+
if: env.FIX_NEEDED == 'true' && env.EXISTING_PR != 'true'
5364
uses: repo-sync/pull-request@v2
5465
with:
5566
source_branch: ${{ env.branch_name }}

0 commit comments

Comments
 (0)