Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support single-subject attestations #219

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove attestationSubjects
  • Loading branch information
AA-Turner committed Mar 1, 2025
commit 7d6949838a129dbebfb4614731f344fecf95a99a
6 changes: 1 addition & 5 deletions src/attest.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ const OCI_RETRY = 3
export type SigstoreInstance = 'public-good' | 'github'
export type AttestResult = Attestation & {
attestationDigest?: string
attestationSubjects: Subject[]
}

export const createAttestation = async (
@@ -29,10 +28,7 @@ export const createAttestation = async (
token: opts.githubToken
})

const result: AttestResult = {
...attestation,
attestationSubjects: subjects
}
const result: AttestResult = attestation

if (subjects.length === 1 && opts.pushToRegistry) {
const subject = subjects[0]
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ import {
subjectFromInputs
} from './subject'

import type { Subject } from '@actions/attest'

const ATTESTATION_FILE_NAME = 'attestation.json'

export type RunInputs = SubjectInputs &
@@ -84,7 +86,7 @@ export async function run(inputs: RunInputs): Promise<void> {
}

for (const att of atts) {
logAttestation(att, sigstoreInstance)
logAttestation(subjects, att, sigstoreInstance)

// Write attestation bundle to output file
fs.writeFileSync(outputPath, JSON.stringify(att.bundle) + os.EOL, {
@@ -124,10 +126,10 @@ export async function run(inputs: RunInputs): Promise<void> {

// Log details about the attestation to the GitHub Actions run
const logAttestation = (
subjects: Subject[],
attestation: AttestResult,
sigstoreInstance: SigstoreInstance
): void => {
const subjects = attestation.attestationSubjects
if (subjects.length === 1) {
core.info(
`Attestation created for ${subjects[0].name}@${formatSubjectDigest(subjects[0])}`