Skip to content

Commit 0496517

Browse files
committed
Limit number of cleanup PRs
currently an unlimited number of PRs are created for cleanups. Especially when enabling new cleanups this can lead to a massive amount of PRs created what are hard to manage and probably block the CI. This now enables a limit of 10 open PRs at a time.
1 parent cf05ba6 commit 0496517

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

.github/workflows/cleanCode.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,24 @@ jobs:
7878
max-parallel: 1
7979
fail-fast: false
8080
steps:
81+
- name: List number of open PRs
82+
id: list-prs
83+
run: |
84+
json_output=$(gh pr list -l 'cleanup' -R $OWNER/$REPO -L 100 --json id)
85+
echo "prs=$json_output" | tee -a "$GITHUB_OUTPUT"
86+
env:
87+
GH_TOKEN: ${{ secrets.token }}
88+
OWNER: ${{ github.repository_owner }}
89+
REPO: ${{ github.event.repository.name }}
90+
- name: Cancel job if to much open PRs
91+
if: fromJson(steps.list-prs.outputs.prs)[9] != null
92+
run: |
93+
gh run cancel -R $OWNER/$REPO ${{ github.run_id }}
94+
gh run watch -R $OWNER/$REPO ${{ github.run_id }}
95+
env:
96+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
OWNER: ${{ github.repository_owner }}
98+
REPO: ${{ github.event.repository.name }}
8199
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82100
with:
83101
fetch-depth: 0
@@ -108,7 +126,7 @@ jobs:
108126
xvfb-run mvn -B -ntp tycho-cleancode:quickfix@quickfixes
109127
- name: Create final PR description
110128
working-directory: ${{ matrix.bundles }}/target
111-
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' }} || ${{ hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
129+
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' || hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
112130
run: >-
113131
cat *.md > pr.md
114132
- name: Create Pull Request

0 commit comments

Comments
 (0)