Skip to content

Commit 82b2172

Browse files
committed
ci: build and push image to ghcr.io
Signed-off-by: Emanuele Di Pascale <[email protected]>
1 parent c3de074 commit 82b2172

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish Docker Image
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- "v*"
8+
9+
# based on https://docs.github.com/en/actions/tutorials/publish-packages/publish-docker-images
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build-and-push-image:
17+
name: Build Docker container and push it to GitHub registry
18+
runs-on: ubuntu-latest
19+
permissions:
20+
packages: write
21+
contents: read
22+
attestations: write
23+
id-token: write
24+
steps:
25+
- name: Check out the repo
26+
uses: actions/checkout@v5
27+
28+
- name: Login to ghcr.io
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
41+
- name: Build and push Docker image
42+
id: push
43+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
44+
with:
45+
context: .
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
50+
- name: Generate artifact attestation
51+
uses: actions/attest-build-provenance@v3
52+
with:
53+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
subject-digest: ${{ steps.push.outputs.digest }}
55+
push-to-registry: true

0 commit comments

Comments
 (0)