send api errors to gha debug log (#59)

Signed-off-by: Brian DeHamer <[email protected]>
This commit is contained in:
Brian DeHamer
2024-05-09 12:34:14 -07:00
committed by GitHub
parent b0d8b47eb7
commit 58fa41a101
2 changed files with 23 additions and 0 deletions
+12
View File
@@ -19,11 +19,21 @@ const ATTESTATION_FILE_NAME = 'attestation.jsonl'
const MAX_SUBJECT_COUNT = 64
/* istanbul ignore next */
const logHandler = (level: string, ...args: unknown[]): void => {
// Send any HTTP-related log events to the GitHub Actions debug log
if (level === 'http') {
core.debug(args.join(' '))
}
}
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
process.on('log', logHandler)
// Provenance visibility will be public ONLY if we can confirm that the
// repository is public AND the undocumented "private-signing" arg is NOT set.
// Otherwise, it will be private.
@@ -98,6 +108,8 @@ export async function run(): Promise<void> {
mute(innerErr instanceof Error ? innerErr.toString() : `${innerErr}`)
)
}
} finally {
process.removeListener('log', logHandler)
}
}