Skip to content

Commit c998de2

Browse files
authored
refactor: update Docker workflows to use reusable configuration and restrict branch triggers to 'main' (#15)
* refactor: update Docker workflows to use reusable configuration and restrict branch triggers to 'main'
1 parent 31ef8bc commit c998de2

File tree

5 files changed

+107
-24
lines changed

5 files changed

+107
-24
lines changed

.github/workflows/docker-image-backend.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ name: Backend Docker Image CI
22

33
on:
44
push:
5-
branches: [ "develop_930" ]
5+
branches: [ "main" ]
66
paths:
77
- 'backend/**'
88
- 'scripts/images/backend/**'
99
- '.github/workflows/docker-image-backend.yml'
1010
pull_request:
11-
branches: [ "develop_930" ]
11+
branches: [ "main" ]
1212
paths:
1313
- 'backend/**'
1414
- 'scripts/images/backend/**'
1515
- '.github/workflows/docker-image-backend.yml'
1616
workflow_dispatch:
1717

1818
jobs:
19-
20-
build:
21-
22-
runs-on: ubuntu-latest
23-
24-
steps:
25-
- uses: actions/checkout@v4
26-
- name: Build the Backend Docker image
27-
run: make build-backend
19+
call-docker-build:
20+
name: Build and Push Backend Docker Image
21+
uses: ./.github/workflows/docker-images-reusable.yml
22+
permissions:
23+
contents: read
24+
packages: write
25+
with:
26+
service_name: backend
27+
build_dir: .

.github/workflows/docker-image-frontend.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ name: Frontend Docker Image CI
22

33
on:
44
push:
5-
branches: [ "develop_930" ]
5+
branches: [ "main" ]
66
paths:
77
- 'frontend/**'
88
- 'scripts/images/frontend/**'
99
- '.github/workflows/docker-image-frontend.yml'
1010
pull_request:
11-
branches: [ "develop_930" ]
11+
branches: [ "main" ]
1212
paths:
1313
- 'frontend/**'
1414
- 'scripts/images/frontend/**'
1515
- '.github/workflows/docker-image-frontend.yml'
1616
workflow_dispatch:
1717

1818
jobs:
19-
20-
build:
21-
22-
runs-on: ubuntu-latest
23-
24-
steps:
25-
- uses: actions/checkout@v4
26-
- name: Build the Frontend Docker image
27-
run: make build-frontend
19+
call-docker-build:
20+
name: Build and Push Frontend Docker Image
21+
uses: ./.github/workflows/docker-images-reusable.yml
22+
permissions:
23+
contents: read
24+
packages: write
25+
with:
26+
service_name: frontend
27+
build_dir: .
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Runtime Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'runtime/**'
8+
- 'scripts/images/runtime/**'
9+
- '.github/workflows/docker-image-runtime.yml'
10+
pull_request:
11+
branches: [ "main" ]
12+
paths:
13+
- 'runtime/**'
14+
- 'scripts/images/runtime/**'
15+
- '.github/workflows/docker-image-runtime.yml'
16+
workflow_dispatch:
17+
18+
jobs:
19+
call-docker-build:
20+
name: Build and Push Runtime Docker Image
21+
uses: ./.github/workflows/docker-images-reusable.yml
22+
permissions:
23+
contents: read
24+
packages: write
25+
with:
26+
service_name: runtime
27+
build_dir: .
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Docker Image Build & Push
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
service_name:
7+
required: true
8+
type: string
9+
build_dir:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Login to GitHub Container Registry
24+
if: github.event_name != 'pull_request'
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set Docker Image Tag
32+
id: set-tag
33+
run: |
34+
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
35+
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
36+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
37+
TAG=${GITHUB_REF#refs/tags/v}
38+
echo "TAGS=$BASE_IMAGE:$TAG" >> $GITHUB_OUTPUT
39+
elif [[ $GITHUB_REF == refs/heads/main ]]; then
40+
echo "TAGS=$BASE_IMAGE:latest" >> $GITHUB_OUTPUT
41+
else
42+
echo "TAGS=$BASE_IMAGE:temp" >> $GITHUB_OUTPUT
43+
fi
44+
45+
- name: Build Docker Image
46+
run: |
47+
make build-${{ inputs.service_name }} VERSION=latest
48+
49+
- name: Tag Docker Image
50+
run: |
51+
docker tag datamate-${{ inputs.service_name }}:latest ${{ steps.set-tag.outputs.TAGS }}
52+
53+
- name: Push Docker Image
54+
if: github.event_name != 'pull_request'
55+
run: |
56+
docker push ${{ steps.set-tag.outputs.TAGS }}
57+

README-zh.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
![GitHub Issues](https://img.shields.io/github/issues/ModelEngine-Group/DataMate)
1010
![GitHub License](https://img.shields.io/github/license/ModelEngine-Group/DataMate)
1111

12-
**DataMate是面向模型微调与RAG检索的企业级数据处理平台,支持数据归集、数据管理、算子市场、数据清洗、数据合成、数据标注、数据评估、知识生成等核心功能。
13-
**
12+
**DataMate是面向模型微调与RAG检索的企业级数据处理平台,支持数据归集、数据管理、算子市场、数据清洗、数据合成、数据标注、数据评估、知识生成等核心功能。**
1413

1514
[简体中文](./README-zh.md) | [English](./README.md)
1615

0 commit comments

Comments
 (0)