init attest build provenance

This commit is contained in:
ejahnGithub
2024-02-22 08:29:05 -08:00
parent 1a4323c55b
commit 381fca5703
45 changed files with 76808 additions and 372 deletions
+8 -14
View File
@@ -1,5 +1,5 @@
import { generateProvenancePredicate } from '@actions/attest'
import * as core from '@actions/core'
import { wait } from './wait'
/**
* The main function for the action.
@@ -7,20 +7,14 @@ import { wait } from './wait'
*/
export async function run(): Promise<void> {
try {
const ms: string = core.getInput('milliseconds')
// Calculate subject from inputs and generate provenance
const predicate = generateProvenancePredicate(process.env)
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
core.debug(`Waiting ${ms} milliseconds ...`)
// Log the current timestamp, wait, then log the new timestamp
core.debug(new Date().toTimeString())
await wait(parseInt(ms, 10))
core.debug(new Date().toTimeString())
// Set outputs for other workflow steps to use
core.setOutput('time', new Date().toTimeString())
} catch (error) {
core.setOutput('predicate', predicate.params)
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
if (error instanceof Error) core.setFailed(error.message)
core.setFailed(error.message)
}
}
-14
View File
@@ -1,14 +0,0 @@
/**
* Wait for a number of milliseconds.
* @param milliseconds The number of milliseconds to wait.
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
*/
export async function wait(milliseconds: number): Promise<string> {
return new Promise(resolve => {
if (isNaN(milliseconds)) {
throw new Error('milliseconds not a number')
}
setTimeout(() => resolve('done!'), milliseconds)
})
}