Skip to content

Commit acdedcf

Browse files
workflows: stop using github-script for download (#933)
This patch changes the way build_url artifact is downloaded when running test-pr workflow. The workflow is triggered by build on PR submission. It downloads the build_url file from the triggering workflow. In case triggering workflow contains more than 30 artifacts the download may fail. This is caused by pagination in github REST API. This patch removes use of github-script. Instead it uses dawidd6/action-download-artifact action which allows to download artifacts from triggering workflow. Using the action has additional benefit of removin "unzip" step.
2 parents 90e90d9 + eb5b572 commit acdedcf

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

.github/workflows/test-pr.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,15 @@ jobs:
2222
url: ${{ steps.set-build-url.outputs.url }}
2323
steps:
2424
- name: 'Download build URL'
25-
uses: actions/github-script@v6
25+
id: download-artifact
26+
uses: actions/download-artifact@v4
2627
with:
27-
script: |
28-
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
29-
owner: context.repo.owner,
30-
repo: context.repo.repo,
31-
run_id: context.payload.workflow_run.id,
32-
});
33-
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
34-
return artifact.name == "build_url"
35-
})[0];
36-
let download = await github.rest.actions.downloadArtifact({
37-
owner: context.repo.owner,
38-
repo: context.repo.repo,
39-
artifact_id: matchArtifact.id,
40-
archive_format: 'zip',
41-
});
42-
const fs = require('fs');
43-
const path = require('path');
44-
const temp = '${{ runner.temp }}/artifacts';
45-
if (!fs.existsSync(temp)){
46-
fs.mkdirSync(temp);
47-
}
48-
fs.writeFileSync(path.join(temp, 'build_url.zip'), Buffer.from(download.data));
49-
28+
run-id: ${{ github.event.workflow_run.id }}
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
name: build_url
5031
- name: 'Setup build URL'
5132
id: set-build-url
5233
run: |
53-
unzip "${{ runner.temp }}/artifacts/build_url.zip"
5434
BUILD_URL=$(cat build_url)
5535
echo "Build URL: ${BUILD_URL}"
5636
echo "url=${BUILD_URL}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)