Skip to content

Commit 58fa41a

Browse files
authored
send api errors to gha debug log (#59)
Signed-off-by: Brian DeHamer <bdehamer@github.com>
1 parent b0d8b47 commit 58fa41a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

dist/index.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ const ATTESTATION_FILE_NAME = 'attestation.jsonl'
1919

2020
const MAX_SUBJECT_COUNT = 64
2121

22+
/* istanbul ignore next */
23+
const logHandler = (level: string, ...args: unknown[]): void => {
24+
// Send any HTTP-related log events to the GitHub Actions debug log
25+
if (level === 'http') {
26+
core.debug(args.join(' '))
27+
}
28+
}
29+
2230
/**
2331
* The main function for the action.
2432
* @returns {Promise<void>} Resolves when the action is complete.
2533
*/
2634
export async function run(): Promise<void> {
35+
process.on('log', logHandler)
36+
2737
// Provenance visibility will be public ONLY if we can confirm that the
2838
// repository is public AND the undocumented "private-signing" arg is NOT set.
2939
// Otherwise, it will be private.
@@ -98,6 +108,8 @@ export async function run(): Promise<void> {
98108
mute(innerErr instanceof Error ? innerErr.toString() : `${innerErr}`)
99109
)
100110
}
111+
} finally {
112+
process.removeListener('log', logHandler)
101113
}
102114
}
103115

0 commit comments

Comments
 (0)