-
Notifications
You must be signed in to change notification settings - Fork 3k
188 lines (175 loc) · 6.98 KB
/
Copy pathllama-cpp-image-attest.yaml
File metadata and controls
188 lines (175 loc) · 6.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: Attest llama.cpp server image
on:
workflow_call:
inputs:
candidate_tag:
description: Run-unique candidate tag
required: true
type: string
digest:
description: Exact candidate index digest
required: true
type: string
image:
description: Owned llama.cpp server image repository
required: true
type: string
retention_days:
description: Evidence artifact retention in days
required: true
type: number
sbom_format:
description: SBOM document format
required: true
type: string
permissions: {}
jobs:
validate-inputs:
name: Validate attestation inputs
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions: {}
outputs:
candidate_tag: ${{ steps.validate.outputs.candidate_tag }}
digest: ${{ steps.validate.outputs.digest }}
image: ${{ steps.validate.outputs.image }}
retention_days: ${{ steps.validate.outputs.retention_days }}
sbom_format: ${{ steps.validate.outputs.sbom_format }}
steps:
- name: Validate exact inputs
id: validate
shell: bash
env:
CALLER_WORKFLOW_REF: ${{ github.workflow_ref }}
INPUT_CANDIDATE_TAG: ${{ inputs.candidate_tag }}
INPUT_DIGEST: ${{ inputs.digest }}
INPUT_IMAGE: ${{ inputs.image }}
INPUT_RETENTION_DAYS: ${{ inputs.retention_days }}
INPUT_SBOM_FORMAT: ${{ inputs.sbom_format }}
run: |
set -euo pipefail
if [ "$GITHUB_REPOSITORY" != "NVIDIA/NemoClaw" ] \
|| [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ] \
|| [ "$GITHUB_REF" != "refs/heads/main" ] \
|| [ "$CALLER_WORKFLOW_REF" != "NVIDIA/NemoClaw/.github/workflows/llama-cpp-image.yaml@refs/heads/main" ]; then
echo "ERROR: attestation caller does not match the trusted main workflow." >&2
exit 1
fi
expected_candidate_tag="llama-cpp-candidate-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
if [ "$INPUT_CANDIDATE_TAG" != "$expected_candidate_tag" ]; then
echo "ERROR: candidate tag does not match llama-cpp-candidate-RUN_ID-RUN_ATTEMPT." >&2
exit 1
fi
if [[ ! "$INPUT_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "ERROR: candidate digest is invalid." >&2
exit 1
fi
if [ "$INPUT_IMAGE" != "ghcr.io/nvidia/nemoclaw/llama-cpp-server" ]; then
echo "ERROR: image repository is not the owned llama.cpp server repository." >&2
exit 1
fi
if [ "$INPUT_SBOM_FORMAT" != "spdx-json" ]; then
echo "ERROR: SBOM format must be spdx-json." >&2
exit 1
fi
if [[ ! "$INPUT_RETENTION_DAYS" =~ ^[1-9][0-9]*$ ]] \
|| [ "$INPUT_RETENTION_DAYS" -gt 90 ]; then
echo "ERROR: evidence retention must be between 1 and 90 days." >&2
exit 1
fi
{
printf 'candidate_tag=%s\n' "$INPUT_CANDIDATE_TAG"
printf 'digest=%s\n' "$INPUT_DIGEST"
printf 'image=%s\n' "$INPUT_IMAGE"
printf 'retention_days=%s\n' "$INPUT_RETENTION_DAYS"
printf 'sbom_format=%s\n' "$INPUT_SBOM_FORMAT"
} >> "$GITHUB_OUTPUT"
attest:
name: Generate and publish image evidence
needs: validate-inputs
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
attestations: write
contents: read
id-token: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Authenticate to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Generate amd64 SPDX SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
env:
SYFT_PLATFORM: linux/amd64
with:
image: ${{ needs.validate-inputs.outputs.image }}@${{ needs.validate-inputs.outputs.digest }}
format: ${{ needs.validate-inputs.outputs.sbom_format }}
artifact-name: llama-cpp-sbom-amd64-${{ needs.validate-inputs.outputs.candidate_tag }}
output-file: llama-cpp-sbom-amd64.spdx.json
upload-artifact: true
upload-artifact-retention: ${{ needs.validate-inputs.outputs.retention_days }}
upload-release-assets: false
- name: Generate arm64 SPDX SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
env:
SYFT_PLATFORM: linux/arm64
with:
image: ${{ needs.validate-inputs.outputs.image }}@${{ needs.validate-inputs.outputs.digest }}
format: ${{ needs.validate-inputs.outputs.sbom_format }}
artifact-name: llama-cpp-sbom-arm64-${{ needs.validate-inputs.outputs.candidate_tag }}
output-file: llama-cpp-sbom-arm64.spdx.json
upload-artifact: true
upload-artifact-retention: ${{ needs.validate-inputs.outputs.retention_days }}
upload-release-assets: false
- name: Install Cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
with:
cosign-release: v3.1.2
- name: Attest amd64 SPDX SBOM
shell: bash
env:
DIGEST: ${{ needs.validate-inputs.outputs.digest }}
IMAGE: ${{ needs.validate-inputs.outputs.image }}
run: |
set -euo pipefail
timeout --foreground 120s cosign attest \
--yes \
--predicate llama-cpp-sbom-amd64.spdx.json \
--type spdxjson \
"$IMAGE@$DIGEST"
- name: Attest arm64 SPDX SBOM
shell: bash
env:
DIGEST: ${{ needs.validate-inputs.outputs.digest }}
IMAGE: ${{ needs.validate-inputs.outputs.image }}
run: |
set -euo pipefail
timeout --foreground 120s cosign attest \
--yes \
--predicate llama-cpp-sbom-arm64.spdx.json \
--type spdxjson \
"$IMAGE@$DIGEST"
- name: Attest SLSA build provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-name: ${{ needs.validate-inputs.outputs.image }}
subject-digest: ${{ needs.validate-inputs.outputs.digest }}
push-to-registry: true
- name: Sign exact candidate index
shell: bash
env:
DIGEST: ${{ needs.validate-inputs.outputs.digest }}
IMAGE: ${{ needs.validate-inputs.outputs.image }}
run: |
set -euo pipefail
timeout --foreground 120s cosign sign --yes "$IMAGE@$DIGEST"