Skip to content

Commit d493f44

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 d493f44

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/cleanCode.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ 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 ${{ github.run_id }}
94+
gh run watch ${{ github.run_id }}
95+
env:
96+
GH_TOKEN: ${{ secrets.token }}
8197
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8298
with:
8399
fetch-depth: 0
@@ -108,7 +124,7 @@ jobs:
108124
xvfb-run mvn -B -ntp tycho-cleancode:quickfix@quickfixes
109125
- name: Create final PR description
110126
working-directory: ${{ matrix.bundles }}/target
111-
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' }} || ${{ hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
127+
if: ${{ hashFiles(format('{0}/target/quickfix.md', matrix.bundles)) != '' || ${{ hashFiles(format('{0}/target/cleanups.md', matrix.bundles)) != '' }}
112128
run: >-
113129
cat *.md > pr.md
114130
- name: Create Pull Request

0 commit comments

Comments
 (0)