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'
This commit is contained in:
Dallas98
2025-10-22 23:44:44 +08:00
committed by GitHub
parent 31ef8bc265
commit c998de2e9d
5 changed files with 107 additions and 24 deletions

View File

@@ -2,13 +2,13 @@ name: Backend Docker Image CI
on:
push:
branches: [ "develop_930" ]
branches: [ "main" ]
paths:
- 'backend/**'
- 'scripts/images/backend/**'
- '.github/workflows/docker-image-backend.yml'
pull_request:
branches: [ "develop_930" ]
branches: [ "main" ]
paths:
- 'backend/**'
- 'scripts/images/backend/**'
@@ -16,12 +16,12 @@ on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Backend Docker image
run: make build-backend
call-docker-build:
name: Build and Push Backend Docker Image
uses: ./.github/workflows/docker-images-reusable.yml
permissions:
contents: read
packages: write
with:
service_name: backend
build_dir: .

View File

@@ -2,13 +2,13 @@ name: Frontend Docker Image CI
on:
push:
branches: [ "develop_930" ]
branches: [ "main" ]
paths:
- 'frontend/**'
- 'scripts/images/frontend/**'
- '.github/workflows/docker-image-frontend.yml'
pull_request:
branches: [ "develop_930" ]
branches: [ "main" ]
paths:
- 'frontend/**'
- 'scripts/images/frontend/**'
@@ -16,12 +16,12 @@ on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Frontend Docker image
run: make build-frontend
call-docker-build:
name: Build and Push Frontend Docker Image
uses: ./.github/workflows/docker-images-reusable.yml
permissions:
contents: read
packages: write
with:
service_name: frontend
build_dir: .

View File

@@ -0,0 +1,27 @@
name: Runtime Docker Image CI
on:
push:
branches: [ "main" ]
paths:
- 'runtime/**'
- 'scripts/images/runtime/**'
- '.github/workflows/docker-image-runtime.yml'
pull_request:
branches: [ "main" ]
paths:
- 'runtime/**'
- 'scripts/images/runtime/**'
- '.github/workflows/docker-image-runtime.yml'
workflow_dispatch:
jobs:
call-docker-build:
name: Build and Push Runtime Docker Image
uses: ./.github/workflows/docker-images-reusable.yml
permissions:
contents: read
packages: write
with:
service_name: runtime
build_dir: .

View File

@@ -0,0 +1,57 @@
name: Docker Image Build & Push
on:
workflow_call:
inputs:
service_name:
required: true
type: string
build_dir:
required: true
type: string
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker Image Tag
id: set-tag
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=$BASE_IMAGE:$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=$BASE_IMAGE:latest" >> $GITHUB_OUTPUT
else
echo "TAGS=$BASE_IMAGE:temp" >> $GITHUB_OUTPUT
fi
- name: Build Docker Image
run: |
make build-${{ inputs.service_name }} VERSION=latest
- name: Tag Docker Image
run: |
docker tag datamate-${{ inputs.service_name }}:latest ${{ steps.set-tag.outputs.TAGS }}
- name: Push Docker Image
if: github.event_name != 'pull_request'
run: |
docker push ${{ steps.set-tag.outputs.TAGS }}

View File

@@ -9,8 +9,7 @@
![GitHub Issues](https://img.shields.io/github/issues/ModelEngine-Group/DataMate)
![GitHub License](https://img.shields.io/github/license/ModelEngine-Group/DataMate)
**DataMate是面向模型微调与RAG检索的企业级数据处理平台,支持数据归集、数据管理、算子市场、数据清洗、数据合成、数据标注、数据评估、知识生成等核心功能。
**
**DataMate是面向模型微调与RAG检索的企业级数据处理平台,支持数据归集、数据管理、算子市场、数据清洗、数据合成、数据标注、数据评估、知识生成等核心功能。**
[简体中文](./README-zh.md) | [English](./README.md)