From 40a270c9d6607a151b9dc4c1e727d606265e7d4f Mon Sep 17 00:00:00 2001
From: suyiiyii <suyiiyii@gmail.com>
Date: Mon, 20 Jan 2025 23:39:54 +0800
Subject: [PATCH] =?UTF-8?q?ci(docker):=20=E6=9B=B4=E6=96=B0=20Docker=20?=
 =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=92=8C=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C?=
 =?UTF-8?q?=E6=B5=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

-为不同的服务添加构建矩阵,支持 facade、auth 和 user 服务- 更新镜像名称,包含服务名称后缀
- 修改构建上下文,针对每个服务单独构建
---
 .github/workflows/docker-publish.yml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 98bd621..50e885d 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -24,6 +24,9 @@ jobs:
   build:
 
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        service: [ "facade", "auth" ,"user" ]
     permissions:
       contents: read
       packages: write
@@ -65,7 +68,7 @@ jobs:
         id: meta
         uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
         with:
-          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.service }}
 
       # Build and push Docker image with Buildx (don't push on PR)
       # https://github.com/docker/build-push-action
@@ -73,7 +76,7 @@ jobs:
         id: build-and-push
         uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
         with:
-          context: .
+          context: app/${{ matrix.service }}/.
           push: ${{ github.event_name != 'pull_request' }}
           tags: ${{ steps.meta.outputs.tags }}
           labels: ${{ steps.meta.outputs.labels }}