error handling

This commit is contained in:
Trym Lund Flogard 2021-06-05 13:27:25 +02:00
parent b52e167ab0
commit 02b35dd9a1
3 changed files with 27 additions and 3 deletions

14
dist/index.js vendored
View File

@ -383,8 +383,15 @@ class NextcloudArtifact {
core.info(`Check run HTML: ${resp.data.html_url}`); core.info(`Check run HTML: ${resp.data.html_url}`);
} }
catch (error) { catch (error) {
core.error(error);
await this.trySetFailed(createResp.data.id);
core.setFailed('Failed to update check');
}
}
async trySetFailed(checkId) {
try {
await this.octokit.rest.checks.update({ await this.octokit.rest.checks.update({
check_run_id: createResp.data.id, check_run_id: checkId,
conclusion: 'failure', conclusion: 'failure',
status: 'completed', status: 'completed',
output: { output: {
@ -392,6 +399,11 @@ class NextcloudArtifact {
}, },
...github.context.repo ...github.context.repo
}); });
return true;
}
catch (error) {
core.error(`Failed to update check status to failure`);
return false;
} }
} }
logUpload(fileCount, rootDirectory) { logUpload(fileCount, rootDirectory) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -95,8 +95,16 @@ export class NextcloudArtifact {
core.info(`Check run URL: ${resp.data.url}`) core.info(`Check run URL: ${resp.data.url}`)
core.info(`Check run HTML: ${resp.data.html_url}`) core.info(`Check run HTML: ${resp.data.html_url}`)
} catch (error) { } catch (error) {
core.error(error)
await this.trySetFailed(createResp.data.id)
core.setFailed('Failed to update check')
}
}
private async trySetFailed(checkId: number) {
try {
await this.octokit.rest.checks.update({ await this.octokit.rest.checks.update({
check_run_id: createResp.data.id, check_run_id: checkId,
conclusion: 'failure', conclusion: 'failure',
status: 'completed', status: 'completed',
output: { output: {
@ -104,6 +112,10 @@ export class NextcloudArtifact {
}, },
...github.context.repo ...github.context.repo
}) })
return true
} catch (error) {
core.error(`Failed to update check status to failure`)
return false
} }
} }