Skip to content

Commit 2c14376

Browse files
committed
ci: add docker image build script
1 parent 9e43b55 commit 2c14376

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build Docker Image
2+
3+
on:
4+
push:
5+
branches: ["main", "dev"]
6+
tags: ["v*"]
7+
workflow_dispatch:
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
12+
jobs:
13+
build-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v3
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Extract Docker metadata
29+
if: ${{ !env.ACT }}
30+
id: meta
31+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ github.repository }}
34+
35+
- name: Log into Container Registry
36+
if: github.event_name != 'pull_request' && ${{ !env.ACT }}
37+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v5
45+
if: github.event_name != 'pull_request' && ${{ !env.ACT }}
46+
with:
47+
context: .
48+
platforms: linux/amd64
49+
push: ${{ github.event_name != 'pull_request' }}
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)