Skip to content

Commit fa1a567

Browse files
committed
feat: add Docker image CI workflow with commit SHA tag
1 parent e1141c1 commit fa1a567

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build Docker image
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- name: Get commit SHA
16+
id: commit
17+
run: |
18+
echo "sha=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
19+
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
platforms: linux/amd64,linux/arm64
38+
push: true
39+
tags: |
40+
ghcr.io/${{ github.repository }}:${{ steps.commit.outputs.sha }}
41+
ghcr.io/${{ github.repository }}:latest
42+
cache-from: type=gha
43+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)