CI build-and-push 前后端并行构建,matrix 策略砍半墙钟时间
This commit is contained in:
@@ -55,6 +55,17 @@ jobs:
|
|||||||
needs: [python-quality, frontend-quality]
|
needs: [python-quality, frontend-quality]
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
runs-on: ubuntu-latest
|
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:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@@ -72,25 +83,29 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
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
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: ${{ matrix.image.context }}
|
||||||
|
file: ${{ matrix.image.file }}
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/yangyuan-zhen/polyweather-backend:latest
|
${{ matrix.image.tag }}:latest
|
||||||
ghcr.io/yangyuan-zhen/polyweather-backend:${{ github.sha }}
|
${{ matrix.image.tag }}:${{ github.sha }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
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
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./frontend
|
context: ${{ matrix.image.context }}
|
||||||
|
file: ${{ matrix.image.file }}
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/yangyuan-zhen/polyweather-frontend:latest
|
${{ matrix.image.tag }}:latest
|
||||||
ghcr.io/yangyuan-zhen/polyweather-frontend:${{ github.sha }}
|
${{ matrix.image.tag }}:${{ github.sha }}
|
||||||
build-args: |
|
build-args: |
|
||||||
NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
|
NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
|
||||||
|
|||||||
Reference in New Issue
Block a user