@@ -219,53 +219,28 @@ runs:
219
219
path : sboms/
220
220
if-no-files-found : error
221
221
222
- - name : Check attestation permissions
223
- id : check_permissions
222
+ - name : Attestation
223
+ continue-on-error : true
224
+ id : attestation
224
225
if : steps.build.outputs.triggered == 'true'
225
- shell : bash
226
- run : |
227
- # Get workflow permissions
228
- PERMISSIONS=$(curl -s -H "Authorization: Bearer ${{ inputs.token }}" \
229
- "https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ github.workflow }}/permissions")
230
-
231
- # Check for both id-token:write and attestations:write permissions
232
- if echo "$PERMISSIONS" | grep -q '"id-token":[[:space:]]*"write"' && \
233
- echo "$PERMISSIONS" | grep -q '"attestations":[[:space:]]*"write"'
234
- then
235
- echo "Both id-token:write and attestations:write permissions are available"
236
- echo "has_permissions=true" >> $GITHUB_OUTPUT
237
- else
238
- echo "Missing required permissions. Both id-token:write and attestations:write are needed for attestation"
239
- fi
240
-
241
- - name : Attest
242
226
uses : actions/attest@v2.3.0
243
- if : steps.build.outputs.triggered == 'true' && steps.check_permissions.outputs.has_permissions == 'true'
244
227
with :
245
228
subject-name : ghcr.io/${{ github.event.repository.name }}/${{ inputs.package }}
246
229
subject-digest : ${{ steps.build_and_push.outputs.digest }}
247
230
predicate-type : ' https://in-toto.io/attestation/release/v0.1'
248
231
predicate : ' {"purl":"pkg:oci/${{ github.event.repository.name }}/${{ inputs.package }}"}'
249
232
233
+ - name : Prompt user to fix permissions
234
+ if : steps.attestation.outcome == 'failure'
235
+ shell : bash
236
+ run : |
237
+ echo "::warning::Attestation skipped due to missing id-token:write and attestations:write permissions. Please update workflow permissions."
238
+
250
239
# Action repo needs to be present for cleanup/tests
251
240
- name : Checkout local repo to make sure action.yml is present
252
241
if : github.repository != inputs.repository
253
242
uses : actions/checkout@v4
254
243
255
- # Get the digest of the built image from the build-push-action output
256
- - name : Validate digest
257
- env :
258
- IMAGE : ghcr.io/${{ steps.vars.outputs.repo_lower }}/${{ steps.vars.outputs.package_lower }}@${{ steps.build_and_push.outputs.digest }}
259
- id : digest
260
- if : steps.build.outputs.triggered == 'true'
261
- shell : bash
262
- run : |
263
- # Validate digest using docker manifest inspect (faster than docker pull)
264
- if ! docker manifest inspect "$IMAGE" > /dev/null; then
265
- echo "Error: Failed to inspect manifest for $IMAGE" >&2
266
- exit 1
267
- fi
268
-
269
244
- name : Print summary outputs
270
245
shell : bash
271
246
run : |
0 commit comments