9696 SECRET_EXAMPLE=$\{{ secrets.SECRET_EXAMPLE }}
9797 ```
9898 required : false
99+ outputs :
100+ build-artifact-id :
101+ description : " ID of the build artifact) uploaded during the build step."
102+ value : ${{ jobs.build.outputs.artifact-id }}
99103
100104permissions : {}
101105
@@ -210,7 +214,7 @@ jobs:
210214 .filter(Boolean)
211215 .map(artifact => {
212216 // FIXME: Workaround to preserve full path to artifact
213- const fullpath = artifact.startsWith('/') ? artifact : `${ workingDirectory}/${ artifact}` ;
217+ const fullpath = artifact.startsWith('/') ? artifact : path.join( workingDirectory, artifact) ;
214218
215219 // Add a wildcard to the first folder of the path
216220 return fullpath.replace(/\/([^/]+)/, '/*$1');
@@ -220,11 +224,8 @@ jobs:
220224 return core.setFailed('No valid build artifact paths found');
221225 }
222226
223- if (!buildArtifact.name) {
224- buildArtifact.name = 'build';
225- } else if (typeof buildArtifact.name !== 'string') {
226- return core.setFailed('Build artifact name must be a string');
227- }
227+ // Generate a unique name for the artifact
228+ buildArtifact.name = `${process.env.GITHUB_JOB}-build-${process.env.GITHUB_RUN_ID}-${Math.random().toString(36).substring(2, 8)}`;
228229
229230 core.setOutput('artifact', JSON.stringify(buildArtifact));
230231 }
@@ -309,6 +310,8 @@ jobs:
309310 contents : read
310311 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
311312 id-token : write
313+ outputs :
314+ artifact-id : ${{ steps.build-artifact-id.outputs.artifact-id }}
312315 steps :
313316 - uses : hoverkraft-tech/ci-github-common/actions/checkout@5f11437c716059f30c635f90055060e4ef8b31a0 # 0.28.0
314317 if : needs.setup.outputs.build-commands && inputs.container == ''
@@ -325,7 +328,8 @@ jobs:
325328 ref : ${{ steps.oidc.outputs.job_workflow_repo_ref }}
326329 sparse-checkout : |
327330 actions
328- - run : |
331+ - if : needs.setup.outputs.build-commands
332+ run : |
329333 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
330334 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
331335 # jscpd:ignore-end
@@ -395,11 +399,13 @@ jobs:
395399 $RUN_SCRIPT_COMMAND "$COMMAND"
396400 done
397401
398- - if : needs.setup.outputs.build-commands && needs.setup.outputs.build-artifact
402+ - id : build-artifact-id
403+ if : needs.setup.outputs.build-commands && needs.setup.outputs.build-artifact
399404 uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
400405 with :
401406 name : ${{ fromJSON(needs.setup.outputs.build-artifact).name }}
402407 path : ${{ fromJSON(needs.setup.outputs.build-artifact).paths }}
408+ if-no-files-found : error
403409
404410 test :
405411 name : 🧪 Test
@@ -420,11 +426,12 @@ jobs:
420426 - uses : hoverkraft-tech/ci-github-common/actions/checkout@5f11437c716059f30c635f90055060e4ef8b31a0 # 0.28.0
421427 if : inputs.container == ''
422428
423- - if : needs.setup .outputs.build- artifact && inputs.container == ''
429+ - if : needs.build .outputs.artifact-id && inputs.container == ''
424430 uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
425431 with :
426- name : build
432+ artifact-ids : ${{ needs. build.outputs.artifact-id }}
427433 path : " /"
434+
428435 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
429436 - id : oidc
430437 uses : ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd # v3
0 commit comments