Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar
path: extract_here
# Optional, defaults to current repo
repo: ${{github.repository}}
# Optional, check the workflow run whether it has an artifact
# then will get the last available artifact from previous workflow
# default false, just try to download from the last one
check_artifacts: false
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ inputs:
description: Where to unpack the artifact
required: false
default: "./"
check_artifacts:
description: Check workflow run whether it has an artifact
required: false
runs:
using: node12
main: main.js
11 changes: 11 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async function main() {
let event = core.getInput("event")
let runID = core.getInput("run_id")
let runNumber = core.getInput("run_number")
let checkArtifacts = core.getInput("check_artifacts")

const client = github.getOctokit(token)

Expand Down Expand Up @@ -75,6 +76,16 @@ async function main() {
if (workflowConclusion && (workflowConclusion != run.conclusion && workflowConclusion != run.status)) {
continue
}
if (checkArtifacts) {
let artifacts = await client.actions.listWorkflowRunArtifacts({
owner: owner,
repo: repo,
run_id: run.id,
})
if (artifacts.data.artifacts.length == 0) {
continue
}
}
runID = run.id
break
}
Expand Down