Skip to content

Commit b6df957

Browse files
committed
Add docker build github actions
1 parent c11bff2 commit b6df957

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
branches: ['feature/github-actions-docker-build']
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
attestations: write
18+
id-token: write
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@v3.4.0
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@v5.7.0
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
36+
- name: Build and push Docker image
37+
id: push
38+
uses: docker/build-push-action@v6.16.0
39+
with:
40+
context: .
41+
push: false
42+
tags: ${{ steps.meta.outputs.tags }}
43+
labels: ${{ steps.meta.outputs.labels }}
44+
45+
- name: Generate artifact attestation
46+
uses: actions/attest-build-provenance@v2
47+
with:
48+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
49+
subject-digest: ${{ steps.push.outputs.digest }}
50+
push-to-registry: false

0 commit comments

Comments
 (0)