Skip to content

Commit 183e2fd

Browse files
Copilotlaeubi
andcommitted
Limit PR creation in checkDependencies.yml to 10 open PRs
Add PR limiting mechanism matching the pattern in cleanCode.yml: - Add list-prs step to count open PRs with 'dependency-check' label - Add if conditions to skip steps when 10+ PRs already exist - Label created PRs with 'dependency-check' for tracking Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
1 parent 33c69a1 commit 183e2fd

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/checkDependencies.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,39 +73,54 @@ jobs:
7373
max-parallel: 1
7474
fail-fast: false
7575
steps:
76+
- name: List number of open PRs
77+
id: list-prs
78+
run: |
79+
json_output=$(gh pr list -l 'dependency-check' -R $OWNER/$REPO -L 20 --json id)
80+
echo "prs=$json_output" | tee -a "$GITHUB_OUTPUT"
81+
env:
82+
GH_TOKEN: ${{ secrets.token }}
83+
OWNER: ${{ github.repository_owner }}
84+
REPO: ${{ github.event.repository.name }}
7685
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
86+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
7787
with:
7888
fetch-depth: 0
7989
ref: master
8090
- name: Set up Maven
8191
uses: stCarolas/setup-maven@12eb41b233df95d49b0c11fc1b5bc8312e5d4ce0 # v5.1
92+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
8293
with:
8394
maven-version: ${{ inputs.mavenVersion }}
8495
- name: Set up JDK
8596
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
97+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
8698
with:
8799
java-version: '21'
88100
distribution: 'temurin'
89101
cache: maven
90102
- name: Check ${{ matrix.bundles }}
91-
working-directory: ${{ matrix.bundles }}
103+
working-directory: ${{ matrix.bundles }}
104+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
92105
run: >-
93106
mvn -B -ntp ${{ inputs.maven-goals }} -DskipTests -Pdependency-check -Dtycho.dependency.check.apply=true
94107
- name: Create PR description file if missing
95-
if: ${{ hashFiles(format('{0}/target/versionProblems.md', matrix.bundles)) == '' }}
108+
if: ${{ hashFiles(format('{0}/target/versionProblems.md', matrix.bundles)) == '' && fromJson(steps.list-prs.outputs.prs)[9] == null }}
96109
working-directory: ${{ matrix.bundles }}
97110
run: |
98111
mkdir -p target
99112
echo '## No version problems detected' > target/versionProblems.md
100113
- name: Create Pull Request
101114
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
115+
if: ${{ fromJson(steps.list-prs.outputs.prs)[9] == null }}
102116
with:
103117
commit-message: Update version ranges of dependencies for ${{ matrix.bundles }}
104118
branch: dependency-check/${{ matrix.bundles }}
105119
title: Update version ranges of dependencies for ${{ matrix.bundles }}
106120
body-path: ${{ matrix.bundles }}/target/versionProblems.md
107121
delete-branch: true
108122
draft: false
123+
labels: dependency-check
109124
token: ${{ secrets.token }}
110125
committer: ${{ inputs.author }}
111126
author: ${{ inputs.author }}

0 commit comments

Comments
 (0)