Skip to content

Commit

Permalink
[BUGFIX] Don't create multiple whitespace Prs (#1496)
Browse files Browse the repository at this point in the history
Co-authored-by: lina.wolf <[email protected]>
  • Loading branch information
github-actions[bot] and linawolf authored Dec 27, 2024
1 parent 81714df commit d4690af
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/apply-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -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 }}
Expand Down

0 comments on commit d4690af

Please sign in to comment.