Skip to content

Commit

Permalink
send api errors to gha debug log (#59)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian DeHamer <bdehamer@github.com>
  • Loading branch information
bdehamer authored May 9, 2024
1 parent b0d8b47 commit 58fa41a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -98,6 +108,8 @@ export async function run(): Promise<void> {
mute(innerErr instanceof Error ? innerErr.toString() : `${innerErr}`)
)
}
} finally {
process.removeListener('log', logHandler)
}
}

Expand Down

0 comments on commit 58fa41a

Please sign in to comment.