2021-09-14 07:33:50 -04:00
|
|
|
import * as core from '@actions/core'
|
2022-06-02 14:17:56 -04:00
|
|
|
import * as setupGradle from './setup-gradle'
|
2024-01-12 13:15:01 -05:00
|
|
|
import {PostActionJobFailure} from './errors'
|
2020-06-13 07:34:07 -04:00
|
|
|
|
2021-11-15 11:21:55 -05:00
|
|
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
|
|
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
|
|
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
|
|
|
process.on('uncaughtException', e => handleFailure(e))
|
|
|
|
|
2021-11-28 12:19:56 -05:00
|
|
|
/**
|
|
|
|
* The post-execution entry point for the action, called by Github Actions after completing all steps for the Job.
|
|
|
|
*/
|
2020-06-13 07:54:27 -04:00
|
|
|
export async function run(): Promise<void> {
|
2021-09-14 07:33:50 -04:00
|
|
|
try {
|
2022-06-02 14:17:56 -04:00
|
|
|
await setupGradle.complete()
|
2021-09-14 07:33:50 -04:00
|
|
|
} catch (error) {
|
2024-01-12 13:15:01 -05:00
|
|
|
if (error instanceof PostActionJobFailure) {
|
|
|
|
core.setFailed(String(error))
|
2024-01-16 19:43:55 -05:00
|
|
|
} else {
|
|
|
|
handleFailure(error)
|
2024-01-12 13:15:01 -05:00
|
|
|
}
|
2021-11-15 11:21:55 -05:00
|
|
|
}
|
2024-01-16 19:43:55 -05:00
|
|
|
|
|
|
|
// Explicit process.exit() to prevent waiting for promises left hanging by `@actions/cache` on save.
|
|
|
|
process.exit()
|
2021-11-15 11:21:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleFailure(error: unknown): void {
|
2022-06-02 14:17:56 -04:00
|
|
|
core.warning(`Unhandled error in Gradle post-action - job will continue: ${error}`)
|
2021-11-15 11:21:55 -05:00
|
|
|
if (error instanceof Error && error.stack) {
|
|
|
|
core.info(error.stack)
|
2021-09-14 07:33:50 -04:00
|
|
|
}
|
2020-06-13 07:34:07 -04:00
|
|
|
}
|
|
|
|
|
2020-06-13 07:44:30 -04:00
|
|
|
run()
|