diff --git a/.github/workflows/download.yml b/.github/workflows/download.yml index 4f09b1b0..41f441ca 100644 --- a/.github/workflows/download.yml +++ b/.github/workflows/download.yml @@ -84,6 +84,6 @@ jobs: workflow: upload.yml name: artifact path: artifact - workflow_conclusion: success + workflow_conclusion: '' - name: Test run: cat artifact/sha | grep $GITHUB_SHA diff --git a/README.md b/README.md index f3dd4157..0ec0f21a 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,10 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar # Required, workflow file name or ID workflow: workflow_name.yml # Optional, the status or conclusion of a completed workflow to search for - # Can be one of a workflow conclusion:: - # "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required" + # Can be one of a workflow conclusion: + #. "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required" # Or a workflow status: - # "completed", "in_progress", "queued" - # Default: "completed,success" + # "completed", "in_progress", "queued" workflow_conclusion: success # Optional, will get head commit SHA pr: ${{github.event.pull_request.number}} diff --git a/action.yml b/action.yml index 0c27e9d6..ac2a779b 100644 --- a/action.yml +++ b/action.yml @@ -14,11 +14,11 @@ inputs: required: true workflow_conclusion: description: | - Wanted status or conclusion or both to search for in recent runs + Wanted status or conclusion to search for in recent runs https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs required: false - default: completed,success + default: success repo: description: Repository name with owner (like actions/checkout) required: false diff --git a/main.js b/main.js index 1e141c3c..738ea408 100644 --- a/main.js +++ b/main.js @@ -63,27 +63,32 @@ async function main() { workflow_id: workflow, branch: branch, event: event, - status: workflowConclusion, } )) { - const run = runs.data.find(r => { - if (commit) { - return r.head_sha == commit + for (const run of runs.data) { + if (commit && run.head_sha != commit) { + continue } - if (runNumber) { - return r.run_number == runNumber + if (runNumber && run.run_number != runNumber) { + continue + } + if (workflowConclusion && (workflowConclusion != run.conclusion && workflowConclusion != run.status)) { + continue } - return true - }) - - if (run) { runID = run.id break } + if (runID) { + break + } } } - console.log("==> RunID:", runID) + if (runID) { + console.log("==> RunID:", runID) + } else { + throw new Error("no matching workflow run found") + } let artifacts = await client.paginate(client.actions.listWorkflowRunArtifacts, { owner: owner,