Skip to content

Commit d0c1fa9

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 8890a04 commit d0c1fa9

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/cleanCode.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,28 @@ 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 }}
8190
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
91+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
8292
with:
8393
fetch-depth: 0
8494
ref: master
8595
- name: Set up Maven
8696
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1 # v5
97+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
8798
with:
8899
maven-version: ${{ inputs.mavenVersion }}
89100
- name: Set up JDK
90101
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
102+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
91103
with:
92104
java-version: |
93105
8
@@ -98,17 +110,17 @@ jobs:
98110
cache: maven
99111
- name: Perform Cleanups on ${{ matrix.bundles }}
100112
working-directory: ${{ matrix.bundles }}
101-
if: ${{ inputs.do-cleanups }}
113+
if: ${{ inputs.do-cleanups && fromJson(steps.list-prs.outputs.prs)[9] == null }}
102114
run: >-
103115
xvfb-run mvn -B -ntp tycho-cleancode:cleanup@cleanups
104116
- name: Perform QuickFixes on ${{ matrix.bundles }}
105117
working-directory: ${{ matrix.bundles }}
106-
if: ${{ inputs.do-quickfix }}
118+
if: ${{ inputs.do-quickfix && fromJson(steps.list-prs.outputs.prs)[9] == null }}
107119
run: >-
108120
xvfb-run mvn -B -ntp tycho-cleancode:quickfix@quickfixes
109121
- name: Create final PR description
110122
working-directory: ${{ matrix.bundles }}/target
111-
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' }} || ${{ hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
123+
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' || hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
112124
run: >-
113125
cat *.md > pr.md
114126
- name: Create Pull Request

0 commit comments

Comments
 (0)