Skip to content

Commit c3853e3

Browse files
MasonXonmason
andauthored
feat: Enable docker images auto build when tag pushed (#27)
Co-authored-by: mason <[email protected]>
1 parent 36bffba commit c3853e3

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to Docker Hub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
30+
- name: Log in to ACR
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ secrets.ACR_USERNAME }}
34+
password: ${{ secrets.ACR_PASSWORD }}
35+
registry: ${{ secrets.ACR_REGISTRY }}
36+
37+
- name: Set Docker image tag
38+
id: tag
39+
run: |
40+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
41+
echo "TAGS=opencsghq/dataflow:${GITHUB_REF_NAME},${{ secrets.ACR_REGISTRY }}/opencsghq/dataflow:${GITHUB_REF_NAME}" >> $GITHUB_ENV
42+
else
43+
echo "TAGS=opencsghq/dataflow:latest,${{ secrets.ACR_REGISTRY }}/opencsghq/dataflow:latest" >> $GITHUB_ENV
44+
fi
45+
46+
- name: Build and push Docker image
47+
uses: docker/build-push-action@v6
48+
with:
49+
context: .
50+
file: ./Dockerfile
51+
push: true
52+
provenance: false
53+
tags: ${{ env.TAGS }}
54+
platforms: linux/amd64,linux/arm64

0 commit comments

Comments
 (0)