@@ -19,9 +19,9 @@ outputs:
1919 The filename of the downloaded artifact or the empty string if the
2020 artifact was not found.
2121 value : ${{ steps.download-artifact.outputs.filename }}
22- artifact-id :
22+ artifact-ids :
2323 description : " The id of the artifact being downloaded."
24- value : ${{ steps.artifact-url.outputs.id }}
24+ value : ${{ steps.artifact-url.outputs.ids }}
2525
2626
2727runs :
@@ -36,46 +36,67 @@ runs:
3636 response = await github.rest.actions.listArtifactsForRepo({
3737 owner: context.repo.owner,
3838 repo: context.repo.repo,
39- name: "${{ inputs.artifact-name }}"
4039 })
4140 } else {
4241 response = await github.rest.actions.listWorkflowRunArtifacts({
4342 owner: context.repo.owner,
4443 repo: context.repo.repo,
4544 run_id: "${{ inputs.run-id }}",
46- name: "${{ inputs.artifact-name }}"
4745 })
4846 }
4947
5048 console.log(response)
5149
50+ artifacts_to_download = []
5251 for (artifact of response.data.artifacts) {
52+ if (artifact.name.startsWith("${{ inputs.artifact-name }}")) {
53+ artifacts_to_download.push(artifact)
54+ }
55+ }
56+
57+ for (artifact of artifacts_to_download) {
5358 console.log(artifact);
5459 }
5560
56- if (response.data.artifacts .length == 0) {
57- console.log("Could not find artifact ${{ inputs.artifact-name }} for workflow run ${{ inputs.run-id }}")
61+ if (artifacts_to_download .length == 0) {
62+ console.log("Could not find artifacts starting with name ${{ inputs.artifact-name }} for workflow run ${{ inputs.run-id }}")
5863 return;
5964 }
6065
61- const url_response = await github.rest.actions.downloadArtifact({
62- owner: context.repo.owner,
63- repo: context.repo.repo,
64- artifact_id: response.data.artifacts[0].id,
65- archive_format: "zip"
66- })
66+ artifact_ids = []
67+ artifact_urls = []
68+ artifact_names = []
69+ for (artifact_to_download of artifacts_to_download) {
70+ const url_response = await github.rest.actions.downloadArtifact({
71+ owner: context.repo.owner,
72+ repo: context.repo.repo,
73+ artifact_id: artifact_to_download.id,
74+ archive_format: "zip"
75+ })
76+
77+ artifact_ids.push(artifact_to_download.id)
78+ artifact_urls.push('"' + url_response.url + '"')
79+ artifact_names.push('"' + artifact_to_download.name + '"')
80+ }
6781
68- core.setOutput("url", url_response.url);
69- core.setOutput("id", response.data.artifacts[0].id);
82+ core.setOutput("urls", artifact_urls.join(" "));
83+ core.setOutput("ids", artifact_ids.join(" "));
84+ core.setOutput("names", artifact_names.join(" "));
7085
7186 - shell : bash
72- if : steps.artifact-url.outputs.url != ''
87+ if : steps.artifact-url.outputs.urls != ''
7388 id : download-artifact
7489 run : |
75- curl -L -o ${{ inputs.artifact-name }}.zip "${{ steps.artifact-url.outputs.url }}"
76- echo "filename=${{ inputs.artifact-name }}.zip" >> $GITHUB_OUTPUT
90+ artifact_urls=(${{ steps.artifact-url.outputs.urls }})
91+ artifact_names=(${{ steps.artifact-url.outputs.names }})
92+ for i in "${!artifact_urls[@]}"; do
93+ curl -L -o "${artifact_names[$i]}.zip" "${artifact_urls[$i]}"
94+ done
7795
7896 - shell : bash
79- if : steps.download- artifact.outputs.filename != ''
97+ if : steps.artifact-url .outputs.names != ''
8098 run : |
81- unzip ${{ steps.download-artifact.outputs.filename }}
99+ artifact_names=(${{ steps.artifact-url.outputs.names }})
100+ for name in "${artifact_names[@]}"; do
101+ unzip "${name}.zip"
102+ done
0 commit comments