Skip to content

Commit 6412d73

Browse files
committed
Fixed workflow dependencies and artifact handling in test-registry-artifacts.yml
1 parent b076849 commit 6412d73

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

.github/workflows/test-registry-artifacts.yml

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,11 @@ jobs:
431431

432432
- name: Download Artifacts
433433
uses: actions/download-artifact@v3
434+
435+
- name: List Downloaded Artifacts
436+
run: |
437+
echo "Downloaded artifacts:"
438+
find . -type f -name "*.*" | sort
434439
435440
- name: Install OPA and Cosign
436441
run: |
@@ -444,16 +449,26 @@ jobs:
444449
chmod +x cosign-linux-amd64
445450
sudo mv cosign-linux-amd64 /usr/local/bin/cosign
446451
447-
- name: Extract Artifacts
452+
- name: Create Build Metadata
448453
run: |
449-
# Extract policies
450-
mkdir -p temp-policies
451-
tar -xf signed-policies/signed-policies.tar.gz -C temp-policies
452-
cp -r temp-policies/policies .
453-
454-
# Create image metadata files
455-
cat image-digests/image-digests.txt
456-
source image-digests/image-digests.txt
454+
# Create build metadata
455+
cat > build-metadata.json << EOF
456+
{
457+
"builder_id": "github-actions",
458+
"build_type": "Release",
459+
"source_repo": "${{ github.server_url }}/${{ github.repository }}",
460+
"commit_hash": "${{ github.sha }}",
461+
"build_timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
462+
"build_platform": "linux"
463+
}
464+
EOF
465+
466+
- name: Create Image Data Files
467+
run: |
468+
# Read image digests
469+
EXTERNAL_DIGEST=$(cat image-digests/image-digests.txt | grep EXTERNAL_DIGEST | cut -d= -f2)
470+
BUILDER_DIGEST=$(cat image-digests/image-digests.txt | grep BUILDER_DIGEST | cut -d= -f2)
471+
WEBGEN_DIGEST=$(cat image-digests/image-digests.txt | grep WEBGEN_DIGEST | cut -d= -f2)
457472
458473
# Create image metadata files for in-toto attestations
459474
cat > external-image-data.json << EOF
@@ -476,21 +491,13 @@ jobs:
476491
"image_digest": "${WEBGEN_DIGEST}"
477492
}
478493
EOF
479-
480-
# Create build metadata
481-
cat > build-metadata.json << EOF
482-
{
483-
"builder_id": "github-actions",
484-
"build_type": "Release",
485-
"source_repo": "${{ github.server_url }}/${{ github.repository }}",
486-
"commit_hash": "${{ github.sha }}",
487-
"build_timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
488-
"build_platform": "linux"
489-
}
490-
EOF
491494
492495
- name: Generate Attestations
493496
run: |
497+
# Create the signed-policies directory structure
498+
mkdir -p policies/rego
499+
cp -r signed-policies/policies/rego/* policies/rego/ || echo "Could not copy policies"
500+
494501
# Generate Regular Attestations
495502
opa eval -i build-metadata.json -d policies/rego/build_attestation_policy.rego "data.build_attestation.attestation" -f json > build-attestation-raw.json
496503
@@ -579,6 +586,11 @@ jobs:
579586
580587
- name: Download Artifacts
581588
uses: actions/download-artifact@v3
589+
590+
- name: List Downloaded Artifacts
591+
run: |
592+
echo "Downloaded artifacts for publishing:"
593+
find . -type f -name "*.*" | sort
582594
583595
- name: Install Required Tools
584596
run: |
@@ -734,11 +746,11 @@ jobs:
734746
id: sbom_digests
735747
run: |
736748
REPOSITORY="${{ github.repository_owner }}/${{ github.event.repository.name }}-test"
737-
SBOM_EXTERNAL_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/sbom:external-${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest')
738-
SBOM_BUILDER_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/sbom:builder-${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest')
739-
SBOM_WEBGEN_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/sbom:webgen-${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest')
740-
SIGNATURES_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/signatures:${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest')
741-
POLICIES_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/policies:${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest')
749+
SBOM_EXTERNAL_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/sbom:external-${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest' || echo "sha256:unknown")
750+
SBOM_BUILDER_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/sbom:builder-${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest' || echo "sha256:unknown")
751+
SBOM_WEBGEN_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/sbom:webgen-${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest' || echo "sha256:unknown")
752+
SIGNATURES_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/signatures:${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest' || echo "sha256:unknown")
753+
POLICIES_DIGEST=$(oras discover -o json "ghcr.io/${REPOSITORY}/policies:${VERSION}" 2>/dev/null | jq -r '.manifests[0].digest' || echo "sha256:unknown")
742754
743755
echo "SBOM_EXTERNAL_DIGEST=$SBOM_EXTERNAL_DIGEST" >> $GITHUB_ENV
744756
echo "SBOM_BUILDER_DIGEST=$SBOM_BUILDER_DIGEST" >> $GITHUB_ENV
@@ -750,8 +762,8 @@ jobs:
750762
run: |
751763
REPOSITORY="ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-test"
752764
753-
# Load digests from image-digests.txt
754-
source image-digests/image-digests.txt
765+
# Read image digests
766+
EXTERNAL_DIGEST=$(cat image-digests/image-digests.txt | grep EXTERNAL_DIGEST | cut -d= -f2)
755767
756768
# Create reference manifest pointing to all published artifacts
757769
cat > reference-manifest.json << EOF

0 commit comments

Comments
 (0)