Skip to content

Commit

Permalink
fix: second pass, add parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Sep 18, 2023
1 parent 726bb39 commit 375c60f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar
# "fail", "warn", "ignore"
# default fail
if_no_artifact_found: fail
# Optional, ignore forks when searching for artifacts
# when a branch is specified, this is defaulted to false.
# default true
allow_forks: false
```
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ inputs:
description: Where to unpack the artifact
required: false
default: "./"
allow_forks:
description: Allow forks
required: false
default: true
check_artifacts:
description: Check workflow run whether it has an artifact
required: false
Expand Down
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ async function main() {
let runNumber = core.getInput("run_number")
let checkArtifacts = core.getBooleanInput("check_artifacts")
let searchArtifacts = core.getBooleanInput("search_artifacts")
let allowForks = core.getBooleanInput("allow_forks")
let dryRun = core.getInput("dry_run")

// Using allow_forks lets the user accept any fork, in any situation,
// But if it's not set, we forbid forks if the user is trying to download
// artifacts from a given branch.
const willAcceptForks = allowForks || !branch;

const client = github.getOctokit(token)

core.info(`==> Repository: ${owner}/${repo}`)
Expand Down Expand Up @@ -120,7 +126,7 @@ async function main() {
if (workflowConclusion && (workflowConclusion != run.conclusion && workflowConclusion != run.status)) {
continue
}
if (run.head_repository.full_name !== `${owner}/${repo}`) {
if (!willAcceptForks && run.head_repository.full_name !== `${owner}/${repo}`) {
core.info(`==> Skipping run from fork: ${run.head_repository.full_name}`)
continue;
}
Expand Down

0 comments on commit 375c60f

Please sign in to comment.