|
| 1 | +name: Stage342 External Anchor |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - "docs/session/session_manifest.json" |
| 10 | + - "docs/session/signed_session_manifest.json" |
| 11 | + - "docs/anchors/external_anchor_receipt.json" |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + anchor: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Build GitHub Actions anchor receipt |
| 25 | + run: | |
| 26 | + mkdir -p out/anchors |
| 27 | + python3 - <<'PY' |
| 28 | + import json |
| 29 | + import hashlib |
| 30 | + import os |
| 31 | + from pathlib import Path |
| 32 | + from datetime import datetime, timezone |
| 33 | +
|
| 34 | + manifest = Path("docs/session/session_manifest.json") |
| 35 | + signed = Path("docs/session/signed_session_manifest.json") |
| 36 | +
|
| 37 | + def sha256_file(path): |
| 38 | + return hashlib.sha256(path.read_bytes()).hexdigest() |
| 39 | +
|
| 40 | + receipt = { |
| 41 | + "stage": 342, |
| 42 | + "type": "github_actions_anchor_receipt", |
| 43 | + "repository": os.environ.get("GITHUB_REPOSITORY"), |
| 44 | + "run_id": os.environ.get("GITHUB_RUN_ID"), |
| 45 | + "run_number": os.environ.get("GITHUB_RUN_NUMBER"), |
| 46 | + "workflow": os.environ.get("GITHUB_WORKFLOW"), |
| 47 | + "ref": os.environ.get("GITHUB_REF"), |
| 48 | + "sha": os.environ.get("GITHUB_SHA"), |
| 49 | + "anchored_artifact": "docs/session/session_manifest.json", |
| 50 | + "session_manifest_sha256": sha256_file(manifest), |
| 51 | + "signed_session_manifest_sha256": sha256_file(signed), |
| 52 | + "created_at": datetime.now(timezone.utc).isoformat(), |
| 53 | + "meaning": "This receipt anchors the signed verification session manifest to a GitHub Actions run." |
| 54 | + } |
| 55 | +
|
| 56 | + Path("out/anchors/github_actions_anchor_receipt.json").write_text( |
| 57 | + json.dumps(receipt, ensure_ascii=False, indent=2), |
| 58 | + encoding="utf-8" |
| 59 | + ) |
| 60 | + PY |
| 61 | +
|
| 62 | + - name: Upload anchor artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: stage342-external-anchor-artifacts |
| 66 | + path: out/anchors/github_actions_anchor_receipt.json |
0 commit comments