Skip to content

Commit

Permalink
Add some more diagnostics (#121)
Browse files Browse the repository at this point in the history
* fix: apply artifacts filter also in checkArtifacts.

* fix: change author so I can publish the fix

* change name to avoid conflict

* change name

* fix artifacts.filter

* fix bug

* fix: add break

* More diagnostic output

* print found artifact names.

* fix check artifacts

* fix bug

* prep for PR

* Update action.yml

* Update main.js

* Update main.js

* Update main.js

* Update main.js

* Update main.js

Co-authored-by: Dawid Dziurla <[email protected]>
  • Loading branch information
lovettchris and dawidd6 authored May 31, 2022
1 parent 7a1662b commit 80fcec8
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ async function main() {

const client = github.getOctokit(token)

console.log("==> Workflow:", workflow)
console.log("==> Repo:", owner + "/" + repo)
console.log("==> Conclusion:", workflowConclusion)
console.log("==> Artifact name:", name)
console.log("==> Local path:", path)
console.log("==> Workflow name:", workflow)
console.log("==> Repository:", owner + "/" + repo)
console.log("==> Workflow conclusion:", workflowConclusion)

if (pr) {
console.log("==> PR:", pr)
Expand Down Expand Up @@ -59,6 +61,7 @@ async function main() {
}

if (!runID) {
// Note that the runs are returned in most recent first order.
for await (const runs of client.paginate.iterator(client.actions.listWorkflowRuns, {
owner: owner,
repo: repo,
Expand Down Expand Up @@ -96,6 +99,8 @@ async function main() {
}
}
runID = run.id
console.log("==> (found) Run ID:", runID)
console.log("==> (found) Run date:", run.created_at)
break
}
if (runID) {
Expand All @@ -104,10 +109,8 @@ async function main() {
}
}

if (runID) {
console.log("==> RunID:", runID)
} else {
throw new Error("no matching workflow run found")
if (!runID) {
throw new Error("no matching workflow run found with any artifacts?")
}

let artifacts = await client.paginate(client.actions.listWorkflowRunArtifacts, {
Expand All @@ -118,9 +121,17 @@ async function main() {

// One artifact or all if `name` input is not specified.
if (name) {
artifacts = artifacts.filter((artifact) => {
filtered = artifacts.filter((artifact) => {
return artifact.name == name
})
if (filtered.length == 0) {
console.log("==> (not found) Artifact:", name)
console.log("==> Found the following artifacts instead:")
for (const artifact of artifacts) {
console.log("\t==> (found) Artifact:", artifact.name)
}
}
artifacts = filtered
}

if (dryRun) {
Expand All @@ -143,8 +154,9 @@ async function main() {
}
}

if (artifacts.length == 0)
if (artifacts.length == 0) {
throw new Error("no artifacts found")
}

for (const artifact of artifacts) {
console.log("==> Artifact:", artifact.id)
Expand Down

0 comments on commit 80fcec8

Please sign in to comment.