Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search capability #122

Merged
merged 11 commits into from Nov 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()