Skip to content

Commit dc9c280

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 dc9c280

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

.github/workflows/cleanCode.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,27 @@ 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
8291
with:
8392
fetch-depth: 0
8493
ref: master
8594
- name: Set up Maven
8695
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1 # v5
96+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
8797
with:
8898
maven-version: ${{ inputs.mavenVersion }}
8999
- name: Set up JDK
90100
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
101+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
91102
with:
92103
java-version: |
93104
8
@@ -98,17 +109,17 @@ jobs:
98109
cache: maven
99110
- name: Perform Cleanups on ${{ matrix.bundles }}
100111
working-directory: ${{ matrix.bundles }}
101-
if: ${{ inputs.do-cleanups }}
112+
if: ${{ inputs.do-cleanups && fromJson(steps.list-prs.outputs.prs)[9] == null }}
102113
run: >-
103114
xvfb-run mvn -B -ntp tycho-cleancode:cleanup@cleanups
104115
- name: Perform QuickFixes on ${{ matrix.bundles }}
105116
working-directory: ${{ matrix.bundles }}
106-
if: ${{ inputs.do-quickfix }}
117+
if: ${{ inputs.do-quickfix && fromJson(steps.list-prs.outputs.prs)[9] == null }}
107118
run: >-
108119
xvfb-run mvn -B -ntp tycho-cleancode:quickfix@quickfixes
109120
- name: Create final PR description
110121
working-directory: ${{ matrix.bundles }}/target
111-
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' }} || ${{ hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
122+
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' || hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
112123
run: >-
113124
cat *.md > pr.md
114125
- name: Create Pull Request

0 commit comments

Comments
 (0)