devops: merge paginated results when downloading blobs (#29013)
* The results are paginated by default to return max 30 entries, see
[this
page](https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28).
We use
[octakit.paginate](https://octokit.github.io/rest.js/v20#pagination),
wrapped into
[github-script](60a0d83039)
to automatically load all artifacts urls.
* Also bumped github-script to v7
This commit is contained in:
parent
d023829dd5
commit
a3c38bc1f9
8
.github/actions/download-artifact/action.yml
vendored
8
.github/actions/download-artifact/action.yml
vendored
|
|
@ -18,17 +18,17 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: mkdir -p '${{ inputs.path }}/artifacts'
|
run: mkdir -p '${{ inputs.path }}/artifacts'
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
console.log(`downloading artifacts for workflow_run: ${context.payload.workflow_run.id}`);
|
console.log(`downloading artifacts for workflow_run: ${context.payload.workflow_run.id}`);
|
||||||
console.log(`workflow_run: ${JSON.stringify(context.payload.workflow_run, null, 2)}`);
|
console.log(`workflow_run: ${JSON.stringify(context.payload.workflow_run, null, 2)}`);
|
||||||
const { data } = await github.rest.actions.listWorkflowRunArtifacts({
|
const allArtifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
|
||||||
...context.repo,
|
...context.repo,
|
||||||
run_id: context.payload.workflow_run.id
|
run_id: context.payload.workflow_run.id
|
||||||
});
|
});
|
||||||
console.log('total = ', data.total_count);
|
console.log('total = ', allArtifacts.length);
|
||||||
const artifacts = data.artifacts.filter(a => a.name.startsWith('${{ inputs.namePrefix }}'));
|
const artifacts = allArtifacts.filter(a => a.name.startsWith('${{ inputs.namePrefix }}'));
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
for (const artifact of artifacts) {
|
for (const artifact of artifacts) {
|
||||||
const result = await github.rest.actions.downloadArtifact({
|
const result = await github.rest.actions.downloadArtifact({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue