From c43f92cdebf61fb74e124cea138aab7aa08b06e2 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 26 May 2026 11:18:18 +0800 Subject: [PATCH] =?UTF-8?q?CI=20build-and-push=20=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=B9=B6=E8=A1=8C=E6=9E=84=E5=BB=BA=EF=BC=8Cmatrix=20?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E7=A0=8D=E5=8D=8A=E5=A2=99=E9=92=9F=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e88047ac..3f362558 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,17 @@ jobs: needs: [python-quality, frontend-quality] if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest + strategy: + matrix: + image: + - name: backend + context: . + file: Dockerfile + tag: ghcr.io/yangyuan-zhen/polyweather-backend + - name: frontend + context: ./frontend + file: ./frontend/Dockerfile + tag: ghcr.io/yangyuan-zhen/polyweather-frontend permissions: contents: read packages: write @@ -72,25 +83,29 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push backend image + - name: Build and push backend + if: matrix.image.name == 'backend' uses: docker/build-push-action@v6 with: - context: . + context: ${{ matrix.image.context }} + file: ${{ matrix.image.file }} push: true tags: | - ghcr.io/yangyuan-zhen/polyweather-backend:latest - ghcr.io/yangyuan-zhen/polyweather-backend:${{ github.sha }} + ${{ matrix.image.tag }}:latest + ${{ matrix.image.tag }}:${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max - - name: Build and push frontend image + - name: Build and push frontend + if: matrix.image.name == 'frontend' uses: docker/build-push-action@v6 with: - context: ./frontend + context: ${{ matrix.image.context }} + file: ${{ matrix.image.file }} push: true tags: | - ghcr.io/yangyuan-zhen/polyweather-frontend:latest - ghcr.io/yangyuan-zhen/polyweather-frontend:${{ github.sha }} + ${{ matrix.image.tag }}:latest + ${{ matrix.image.tag }}:${{ github.sha }} build-args: | NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} NEXT_PUBLIC_SUPABASE_ANON_KEY=${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}