Skip to content

Commit 908d9d9

Browse files
authored
github-action: provenance for docker (#218)
1 parent 79842ec commit 908d9d9

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ on:
99
permissions:
1010
contents: read
1111

12+
env:
13+
DOCKER_IMAGE_NAME: opbeans/opbeans-ruby
14+
1215
jobs:
1316

1417
release:
1518
runs-on: ubuntu-latest
16-
19+
permissions:
20+
attestations: write
21+
contents: read
22+
id-token: write
1723
steps:
1824
- uses: actions/checkout@v4
1925

@@ -25,9 +31,28 @@ jobs:
2531
roleId: ${{ secrets.VAULT_ROLE_ID }}
2632
secretId: ${{ secrets.VAULT_SECRET_ID }}
2733

28-
- name: Set version if tags
29-
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
30-
if: startsWith(github.ref, 'refs/tags/v')
34+
- name: Extract metadata (tags, labels)
35+
id: docker-meta
36+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
37+
with:
38+
images: ${{ env.DOCKER_IMAGE_NAME }}
39+
tags: |
40+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
41+
# tag event
42+
type=ref,enable=true,prefix=,suffix=,event=tag
43+
44+
- name: Build and push image
45+
id: docker-push
46+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
47+
with:
48+
context: .
49+
push: true
50+
tags: ${{ steps.docker-meta.outputs.tags }}
51+
labels: ${{ steps.docker-meta.outputs.labels }}
3152

32-
- name: Run publish
33-
run: make publish
53+
- name: Attest image
54+
uses: github-early-access/generate-build-provenance@main
55+
with:
56+
subject-name: ${{ env.DOCKER_IMAGE_NAME }}
57+
subject-digest: ${{ steps.docker-push.outputs.digest }}
58+
push-to-registry: false

0 commit comments

Comments
 (0)