Skip to content

Commit fca51ba

Browse files
committed
refactor: main should fail for non-success conclusions
1 parent ff867bb commit fca51ba

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/main.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getConfig } from "./action.ts";
44
import * as api from "./api.ts";
55
import { getWorkflowRunResult, handleActionFail } from "./await-remote-run.ts";
66
import * as constants from "./constants.ts";
7-
import { WorkflowRunConclusion, WorkflowRunStatus } from "./types.ts";
7+
import { WorkflowRunConclusion } from "./types.ts";
88

99
async function main(): Promise<void> {
1010
try {
@@ -29,21 +29,30 @@ async function main(): Promise<void> {
2929
runId: config.runId,
3030
runTimeoutMs: config.runTimeoutSeconds * 1000,
3131
});
32-
if (result.success) {
33-
core.info(
34-
"Run Completed:\n" +
35-
` Run ID: ${config.runId}\n` +
36-
` Status: ${WorkflowRunStatus.Completed}\n` +
37-
` Conclusion: ${WorkflowRunConclusion.Success}`,
38-
);
39-
} else {
32+
if (!result.success) {
4033
const elapsedTime = Date.now() - startTime;
4134
const failureMsg =
4235
result.reason === "timeout"
4336
? `Timeout exceeded while attempting to await run conclusion (${elapsedTime}ms)`
4437
: `An unsupported value was reached: ${result.value}`;
4538
await handleActionFail(failureMsg, config.runId);
39+
return;
40+
}
41+
42+
const { status, conclusion } = result.value;
43+
if (conclusion === WorkflowRunConclusion.Success) {
44+
core.info(
45+
"Run Completed:\n" +
46+
` Run ID: ${config.runId}\n` +
47+
` Status: ${status}\n` +
48+
` Conclusion: ${conclusion}`,
49+
);
4650
}
51+
52+
await handleActionFail(
53+
`Run has concluded with ${conclusion}`,
54+
config.runId,
55+
);
4756
} catch (error) {
4857
if (error instanceof Error) {
4958
const failureMsg = `Failed: An unhandled error has occurred: ${error.message}`;

0 commit comments

Comments
 (0)