Skip to content

Commit ea5190f

Browse files
committed
chore: enhance CI workflow for docker image 🐳
- Checkout repository. - Log in to the Container registry. - Extract metadata (tags, labels) for Docker. - Build and push Docker image. - Generate artifact attestation.
1 parent cd200d2 commit ea5190f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/deploy_image.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches: ["main"]
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+
- name: Log in to the Container registry
23+
uses: docker/login-action
24+
with:
25+
registry: ${{ env.REGISTRY }}
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.REPO_PASSWD }}
28+
- name: Extract metadata (tags, labels) for Docker
29+
id: meta
30+
uses: docker/metadata-action@v3
31+
with:
32+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
33+
- name: Build and push Docker image
34+
id: push
35+
uses: docker/build-push-action@v2
36+
with:
37+
context: .
38+
push: true
39+
tags: |
40+
latest
41+
${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}
43+
- name: Generate artifact attestation
44+
uses: actions/attest-build-provenance@v2
45+
with:
46+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
47+
subject-digest: ${{ steps.push.outputs.digest }}
48+
push-to-registry: true

0 commit comments

Comments
 (0)