Skip to content

Commit

Permalink
Search capability (#122)
Browse files Browse the repository at this point in the history
Co-authored-by: martcus <marco.lovazzano@accenture.com>
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
  • Loading branch information
3 people committed Nov 23, 2021
1 parent af92a84 commit 09385b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -51,4 +51,7 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar
# then will get the last available artifact from previous workflow
# default false, just try to download from the last one
check_artifacts: false
# Optional, search for the last workflow run whose stored an artifact named as in `name` input
# default false
search_artifacts: false
```
3 changes: 3 additions & 0 deletions action.yml
Expand Up @@ -51,6 +51,9 @@ inputs:
check_artifacts:
description: Check workflow run whether it has an artifact
required: false
search_artifacts:
description: Search workflow runs for artifact with specified name
required: false
runs:
using: node12
main: main.js
12 changes: 11 additions & 1 deletion main.js
Expand Up @@ -20,6 +20,7 @@ async function main() {
let runID = core.getInput("run_id")
let runNumber = core.getInput("run_number")
let checkArtifacts = core.getInput("check_artifacts")
let searchArtifacts = core.getInput("search_artifacts")

const client = github.getOctokit(token)

Expand Down Expand Up @@ -76,7 +77,7 @@ async function main() {
if (workflowConclusion && (workflowConclusion != run.conclusion && workflowConclusion != run.status)) {
continue
}
if (checkArtifacts) {
if (checkArtifacts || searchArtifacts) {
let artifacts = await client.actions.listWorkflowRunArtifacts({
owner: owner,
repo: repo,
Expand All @@ -85,6 +86,14 @@ async function main() {
if (artifacts.data.artifacts.length == 0) {
continue
}
if (searchArtifacts) {
const artifact = artifacts.data.artifacts.find((artifact) => {
return artifact.name == name
})
if (!artifact) {
continue
}
}
}
runID = run.id
break
Expand Down Expand Up @@ -152,3 +161,4 @@ async function main() {
}

main()

0 comments on commit 09385b7

Please sign in to comment.