Skip to content

Commit 4ee29c0

Browse files
committed
add attestation for release images
1 parent ce10eaa commit 4ee29c0

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

.github/workflows/_push_image.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ on:
77
description: "Azure Container Registry to push the image to"
88
required: true
99
type: string
10-
image_tag:
10+
image:
11+
description: "Image to push"
12+
required: true
13+
type: string
14+
tag:
1115
description: "Tag to push the image with"
1216
required: true
1317
type: string
@@ -20,14 +24,26 @@ on:
2024
required: true
2125
type: string
2226

27+
permissions:
28+
id-token: write
29+
contents: read
30+
attestations: write
31+
packages: write
32+
2333
jobs:
2434
push-example-image:
25-
name: Push Image (${{ inputs.image_tag }})
35+
name: Push Image (${{ inputs.image }})
2636
runs-on: ubuntu-latest
2737
steps:
2838
- name: Checkout
2939
uses: actions/checkout@v4
3040

41+
# needed to avoid a bug where imageId and digest output are the same
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v1
44+
with:
45+
version: v0.8.2
46+
3147
- name: Log into Azure
3248
uses: azure/login@v2
3349
with:
@@ -45,8 +61,16 @@ jobs:
4561

4662
- name: Build and Push Docker Image
4763
uses: docker/build-push-action@v5
64+
id: build-image
4865
with:
4966
context: ${{ inputs.docker_context }}
5067
file: ${{ inputs.dockerfile_path }}/Dockerfile
5168
push: true
52-
tags: ${{ inputs.repo_type == 'public' && secrets.AZURE_REGISTRY_URL || inputs.repo_type == 'private' && secrets.TEST_AZURE_REGISTRY_URL }}/${{ inputs.image_tag }}
69+
tags: ${{ inputs.repo_type == 'public' && secrets.AZURE_REGISTRY_URL || inputs.repo_type == 'private' && secrets.TEST_AZURE_REGISTRY_URL }}/${{ inputs.image }}:${{inputs.tag}}
70+
71+
- name: Generate Artifact Attestation
72+
uses: actions/attest-build-provenance@v1
73+
with:
74+
subject-name: ${{ inputs.repo_type == 'public' && secrets.AZURE_REGISTRY_URL || inputs.repo_type == 'private' && secrets.TEST_AZURE_REGISTRY_URL }}/${{ inputs.image }}
75+
subject-digest: 'sha256:${{steps.build-image.outputs.digest}}'
76+
push-to-registry: true

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,16 @@ jobs:
4747
uses: github/codeql-action/analyze@v2
4848

4949
- name: Trivy Security Scan
50-
uses: aquasecurity/trivy-action@0.17.0
50+
uses: aquasecurity/trivy-action@0.28.0
5151
with:
5252
scan-type: 'fs'
5353
scan-ref: '.'
5454
format: 'sarif'
5555
output: 'trivy-results.sarif'
56-
exit-code: 1
5756
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
5857

5958
- name: Upload Trivy scan results to GitHub Security tab
6059
uses: github/codeql-action/upload-sarif@v2
61-
if: always()
6260
with:
6361
sarif_file: 'trivy-results.sarif'
6462

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ jobs:
6363
uses: ./.github/workflows/_push_image.yml
6464
secrets: inherit
6565
with:
66-
image_tag: ${{ needs.parse_tag.outputs.repo_type }}/${{ github.actor }}/acc/samples/${{ needs.parse_tag.outputs.image }}:${{ needs.parse_tag.outputs.image_tag }}
66+
image: ${{ needs.parse_tag.outputs.repo_type }}/${{ github.actor }}/acc/samples/${{ needs.parse_tag.outputs.image }}
67+
tag: ${{ needs.parse_tag.outputs.image_tag }}
6768
docker_context: ${{ fromJson(needs.get_docker_context.outputs.docker_context) }}
6869
repo_type: ${{ needs.parse_tag.outputs.repo_type }}
6970

0 commit comments

Comments
 (0)