Skip to content

Commit ebe718c

Browse files
authored
Update docker-image.yml
1 parent 1d2c776 commit ebe718c

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

.github/workflows/docker-image.yml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,58 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
913
jobs:
1014

1115
build:
1216

1317
runs-on: ubuntu-24.04
1418

19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
1525
steps:
1626
- name: Remove unnecessary files
1727
run: |
1828
sudo rm -rf /usr/share/dotnet
1929
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
20-
- uses: actions/checkout@v4
21-
- name: Build the Docker image
22-
run: docker build . --file Dockerfile --tag hdr-image:$(date +%s)
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Log in to the Container registry
34+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: meta
42+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
46+
- name: Build and push Docker image
47+
id: push
48+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
49+
with:
50+
context: .
51+
push: false
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
55+
- name: Generate artifact attestation
56+
uses: actions/attest-build-provenance@v2
57+
with:
58+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
59+
subject-digest: ${{ steps.push.outputs.digest }}
60+
push-to-registry: false
61+
62+
# - name: Build the Docker image
63+
# run: docker build . --file Dockerfile --tag hdr-image:$(date +%s)

0 commit comments

Comments
 (0)