File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,4 +51,7 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar
5151 # then will get the last available artifact from previous workflow
5252 # default false, just try to download from the last one
5353 check_artifacts : false
54+ # Optional, search for the last workflow run whose stored an artifact named as in `name` input
55+ # default false
56+ search_artifacts : false
5457` ` `
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ inputs:
5151 check_artifacts :
5252 description : Check workflow run whether it has an artifact
5353 required : false
54+ search_artifacts :
55+ description : Search workflow runs for artifact with specified name
56+ required : false
5457runs :
5558 using : node12
5659 main : main.js
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ async function main() {
2020 let runID = core . getInput ( "run_id" )
2121 let runNumber = core . getInput ( "run_number" )
2222 let checkArtifacts = core . getInput ( "check_artifacts" )
23+ let searchArtifacts = core . getInput ( "search_artifacts" )
2324
2425 const client = github . getOctokit ( token )
2526
@@ -76,7 +77,7 @@ async function main() {
7677 if ( workflowConclusion && ( workflowConclusion != run . conclusion && workflowConclusion != run . status ) ) {
7778 continue
7879 }
79- if ( checkArtifacts ) {
80+ if ( checkArtifacts || searchArtifacts ) {
8081 let artifacts = await client . actions . listWorkflowRunArtifacts ( {
8182 owner : owner ,
8283 repo : repo ,
@@ -85,6 +86,14 @@ async function main() {
8586 if ( artifacts . data . artifacts . length == 0 ) {
8687 continue
8788 }
89+ if ( searchArtifacts ) {
90+ const artifact = artifacts . data . artifacts . find ( ( artifact ) => {
91+ return artifact . name == name
92+ } )
93+ if ( ! artifact ) {
94+ continue
95+ }
96+ }
8897 }
8998 runID = run . id
9099 break
@@ -152,3 +161,4 @@ async function main() {
152161}
153162
154163main ( )
164+
You can’t perform that action at this time.
0 commit comments