Skip to content

Commit

Permalink
Increase robustness in case of GitHub API failures (#302)
Browse files Browse the repository at this point in the history
* Increase robustness in case of GitHub API failures

attempt to mitigate #301
  • Loading branch information
fkirc authored Dec 30, 2022
1 parent 12aca0a commit fc7bbd5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
13 changes: 12 additions & 1 deletion dist/index.js

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

18 changes: 14 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,20 @@ async function main(): Promise<void> {
const octokit = new Octokit(getOctokitOptions(token))

// Get and parse the current workflow run.
const {data: apiCurrentRun} = await octokit.rest.actions.getWorkflowRun({
...repo,
run_id: github.context.runId
})
let apiCurrentRun: ApiWorkflowRun = null as unknown as ApiWorkflowRun
try {
const res = await octokit.rest.actions.getWorkflowRun({
...repo,
run_id: github.context.runId
})
apiCurrentRun = res.data
} catch (error) {
core.warning(error as string | Error)
await exitSuccess({
shouldSkip: false,
reason: 'no_transferable_run'
})
}
const currentTreeHash = apiCurrentRun.head_commit?.tree_id
if (!currentTreeHash) {
exitFail(`
Expand Down

0 comments on commit fc7bbd5

Please sign in to comment.