generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.ts
31 lines (26 loc) · 883 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as core from '@actions/core'
import {
parseSBOMFromPath,
storePredicate,
generateSBOMPredicate
} from './sbom'
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {
const sbomPath = core.getInput('sbom-path')
core.debug(`Reading SBOM from ${sbomPath}`)
const sbom = await parseSBOMFromPath(sbomPath)
// Calculate subject from inputs and generate provenance
const predicate = generateSBOMPredicate(sbom)
const predicatePath = storePredicate(predicate)
core.setOutput('predicate-path', predicatePath)
core.setOutput('predicate-type', predicate.type)
} catch (err) {
const error = err instanceof Error ? err : new Error(`${err}`)
// Fail the workflow run if an error occurs
core.setFailed(error.message)
}
}