From 85fc579dadf0e82775e0dee5ffdda8d3014536d8 Mon Sep 17 00:00:00 2001 From: Ashley Pearce Date: Thu, 10 Sep 2026 17:34:17 +0000 Subject: [PATCH] Fix evidence upload: write and upload version-pinned receipt.json; add enforce step --- .github/workflows/grc-gate.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/grc-gate.yml b/.github/workflows/grc-gate.yml index 896baa91..13dedef0 100644 --- a/.github/workflows/grc-gate.yml +++ b/.github/workflows/grc-gate.yml @@ -89,6 +89,8 @@ jobs: echo "sha256=$(cat $BUNDLE.sha256)" >> "$GITHUB_OUTPUT" # ---------- STEP 5: UPLOAD ---------- + # The receipt is written AFTER the bundle upload because it pins the + # bundle's S3 version ID, which only exists once the object is in the vault. - name: Upload to evidence vault if: always() run: | @@ -104,4 +106,29 @@ jobs: --bucket "${{ vars.EVIDENCE_VAULT }}" --key "$KEY" \ --query VersionId --output text) - cat > receipt.json <<-EOF \ No newline at end of file + cat > receipt.json <<-EOF + { + "run_id": "${{ github.run_id }}", + "commit": "${{ github.sha }}", + "event": "${{ github.event_name }}", + "gate_outcome": "${{ steps.gate.outcome }}", + "bundle_key": "$KEY", + "version_id": "$VERSION_ID", + "sha256": "${{ steps.sign.outputs.sha256 }}" + } + EOF + + aws s3 cp receipt.json "s3://${{ vars.EVIDENCE_VAULT }}/runs/${{ github.run_id }}/receipt.json" + echo "Receipt uploaded; bundle pinned to version $VERSION_ID" + + # ---------- STEP 6: ENFORCE ---------- + # Sign/upload run with always() so evidence exists even on failure. + # This step makes sure a failed gate still fails the job. + - name: Enforce gate outcome + if: always() + run: | + if [ "${{ steps.gate.outcome }}" != "success" ]; then + echo "Policy gate did not pass (outcome: ${{ steps.gate.outcome }}). Blocking." + exit 1 + fi + echo "Policy gate passed." \ No newline at end of file