Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getInput, info, setFailed, warning } from '@actions/core';
import { getOctokit } from '@actions/github';
import { RequestError } from '@octokit/request-error';
import {
CommitStatusState,
getCommitHash,
Expand All @@ -20,6 +21,10 @@ interface Inputs {
context?: string;
}

interface ValidationFailedError {
errors: object | string;
}

function getInputs(): Inputs {
const token = getInput('token', { required: true });
const state = validateCommitStatusState(getInput('status', { required: true }));
Expand Down Expand Up @@ -66,7 +71,18 @@ async function run(): Promise<void> {
context: inputs.context,
});
} catch (error) {
setFailed((error as Error).message);
let foundMoreElaborateError = false;
const reqError = error as RequestError;
if (reqError.response !== undefined) {
const errorData = reqError.response.data as ValidationFailedError;
if (typeof errorData.errors === 'string') {
foundMoreElaborateError = true;
setFailed(errorData.errors);
}
}
if (!foundMoreElaborateError) {
setFailed((error as Error).message);
}
}
}

Expand Down
Loading