Skip to content

Commit

Permalink
Exclude current workflow from successful workflow determination (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
viveklak committed Mar 22, 2023
1 parent 4da7c5b commit f571240
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
11 changes: 8 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ async function main(): Promise<void> {
)
})
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
if (error instanceof Error) {
core.error(
error.stack ? `${error.message}:\n${error.stack}` : error.message
)
core.setFailed(error.message)
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ export async function run(opts: RunOpts): Promise<void> {
status: 'success',
per_page: 10
})
if (completed.data.workflow_runs.length > 0) {
const [first] = completed.data.workflow_runs
// We may be run as a dispatch workflow from the currentWorkflowRunId which
// could be marked as complete already. Filter it out.
const previouslyCompleted = completed.data.workflow_runs.filter(
w => w.id !== opts.currentWorkflowRunId
)
if (previouslyCompleted.length > 0) {
const [first] = previouslyCompleted
lastCommit = first.head_sha
core.info(
`Last successfully completed workflow run: ${first.id} for commit: ${lastCommit}`
Expand Down

0 comments on commit f571240

Please sign in to comment.