Skip to content

Commit 94dafeb

Browse files
authored
fix: auto-version-bump action and script (#902)
Signed-off-by: Yi Cai <yicai@redhat.com>
1 parent 192a237 commit 94dafeb

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

.github/workflows/auto-version-bump.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ jobs:
2020
id: set-matrix
2121
run: |
2222
matrix=$(node scripts/ci/generate-auto-bump-matrix.js)
23-
echo "matrix<<EOF" >> $GITHUB_OUTPUT
24-
echo "$matrix" >> $GITHUB_OUTPUT
25-
echo "EOF" >> $GITHUB_OUTPUT
23+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
2624
2725
batch-dispatch:
2826
needs: prepare
@@ -44,8 +42,8 @@ jobs:
4442
env:
4543
GH_TOKEN: ${{ secrets.RHDH_BOT_TOKEN }}
4644
run: |
47-
echo "Triggering version bump for workspace ${{ matrix.workspace }}"
48-
json_input='${{ toJson(matrix.workspace) }}'
45+
echo "Triggering version bump for batch ${{ strategy.job-index }}"
46+
json_input='${{ toJson(matrix.batch) }}'
4947
echo "Rendered json_input: $json_input"
5048
gh workflow run version-bump.yml \
5149
--ref main \

scripts/ci/generate-auto-bump-matrix.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import path from 'path';
1919

2020
const workspacesDir = path.resolve('workspaces');
2121

22-
// Only include directories that contain a `.auto-version-bump` marker file
2322
function getWorkspaceDirs() {
2423
return fs.readdirSync(workspacesDir).filter(entry => {
2524
const dirPath = path.join(workspacesDir, entry);
@@ -29,9 +28,18 @@ function getWorkspaceDirs() {
2928
});
3029
}
3130

32-
const workspaces = getWorkspaceDirs().sort();
31+
function batch(array) {
32+
const BATCH_SIZE = 10;
33+
const batchArray = [];
34+
35+
for (let i = 0; i < array.length; i += BATCH_SIZE) {
36+
batchArray.push(array.slice(i, i + BATCH_SIZE));
37+
}
3338

34-
// Final matrix: one workspace per job
35-
const matrix = workspaces.map(workspace => ({ workspace }));
39+
return batchArray;
40+
}
41+
42+
const workspaces = getWorkspaceDirs().sort();
43+
const batches = batch(workspaces);
3644

37-
console.log(JSON.stringify(matrix));
45+
console.log(JSON.stringify({ batch: batches }));

0 commit comments

Comments
 (0)