Skip to content

Commit

Permalink
cicd use matrix strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmwang committed Nov 18, 2024
1 parent 137200a commit ac05421
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ on:
type: string

jobs:
build-push-backend:
name: Build and Push Backend Image
build-push-image:
name: Build and Push Backend/Frontend Images
runs-on: ubuntu-latest
strategy:
matrix:
image: [backend, frontend]

steps:
- name: Checkout Repository
Expand All @@ -25,24 +28,5 @@ jobs:

- name: Build and Push Image with Tag
run: |
docker build --no-cache --platform=linux/amd64 --target backend-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-backend:${{ inputs.tag }}" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-backend:${{ inputs.tag }}"
build-push-frontend:
name: Build and Push Frontend Image
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Image with Tag
run: |
docker build --no-cache --platform=linux/amd64 --target frontend-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-frontend:${{ inputs.tag }}" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-frontend:${{ inputs.tag }}"
docker build --no-cache --platform=linux/amd64 --target ${{ matrix.image }}-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.tag }}" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.tag }}"

0 comments on commit ac05421

Please sign in to comment.