Skip to content

Commit d0f291c

Browse files
authored
download aritfact from latest run which upload an artifact (dawidd6#88)
1 parent 9895e87 commit d0f291c

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar
4646
path: extract_here
4747
# Optional, defaults to current repo
4848
repo: ${{github.repository}}
49+
# Optional, check the workflow run whether it has an artifact
50+
# then will get the last available artifact from previous workflow
51+
# default false, just try to download from the last one
52+
check_artifacts: false
4953
```

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ inputs:
4848
description: Where to unpack the artifact
4949
required: false
5050
default: "./"
51+
check_artifacts:
52+
description: Check workflow run whether it has an artifact
53+
required: false
5154
runs:
5255
using: node12
5356
main: main.js

main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async function main() {
1919
let event = core.getInput("event")
2020
let runID = core.getInput("run_id")
2121
let runNumber = core.getInput("run_number")
22+
let checkArtifacts = core.getInput("check_artifacts")
2223

2324
const client = github.getOctokit(token)
2425

@@ -75,6 +76,16 @@ async function main() {
7576
if (workflowConclusion && (workflowConclusion != run.conclusion && workflowConclusion != run.status)) {
7677
continue
7778
}
79+
if (checkArtifacts) {
80+
let artifacts = await client.actions.listWorkflowRunArtifacts({
81+
owner: owner,
82+
repo: repo,
83+
run_id: run.id,
84+
})
85+
if (artifacts.data.artifacts.length == 0) {
86+
continue
87+
}
88+
}
7889
runID = run.id
7990
break
8091
}

0 commit comments

Comments
 (0)