Add path to created attestation in a well-known summary file (#252)

* Added a new output file, where the path on local disk to each created
attestation is stored. One attestation per line.

Signed-off-by: Fredrik Skogman <[email protected]>

* Added a section to the readme about the paths file

Signed-off-by: Fredrik Skogman <[email protected]>

* store the file in RUNNER_TEMP

* Ignore writing summary file for created attestations if runner_temp is not set.

* prettier updates

---------

Signed-off-by: Fredrik Skogman <[email protected]>
This commit is contained in:
Fredrik Skogman
2025-06-11 15:53:32 +02:00
committed by GitHub
parent cbc14bbf25
commit 6a89e12864
3 changed files with 34 additions and 0 deletions
+15
View File
@@ -16,6 +16,7 @@ import {
import type { Subject } from '@actions/attest'
const ATTESTATION_FILE_NAME = 'attestation.json'
const ATTESTATION_PATHS_FILE_NAME = 'created_attestation_paths.txt'
export type RunInputs = SubjectInputs &
PredicateInputs & {
@@ -79,6 +80,20 @@ export async function run(inputs: RunInputs): Promise<void> {
flag: 'a'
})
const baseDir = process.env.RUNNER_TEMP
if (baseDir) {
const outputSummaryPath = path.join(baseDir, ATTESTATION_PATHS_FILE_NAME)
// Append the output path to the attestations paths file
fs.appendFileSync(outputSummaryPath, outputPath + os.EOL, {
encoding: 'utf-8',
flag: 'a'
})
} else {
core.warning(
'RUNNER_TEMP environment variable is not set. Cannot write attestation paths file.'
)
}
if (att.attestationID) {
core.setOutput('attestation-id', att.attestationID)
core.setOutput('attestation-url', attestationURL(att.attestationID))