Skip to content

Commit

Permalink
chore: optimize build process
Browse files Browse the repository at this point in the history
  • Loading branch information
infanf committed Aug 10, 2024
1 parent d625507 commit a458a66
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- beta

jobs:
build:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v3'
Expand All @@ -22,6 +22,26 @@ jobs:
type=semver,pattern={{version}}
type=raw,value=release,enable=${{ startsWith(github.ref, 'refs/tags/2.') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/2.') }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Frontend
uses: docker/build-push-action@v3
with:
context: './frontend'
push: false
tags: ${{ steps.meta-frontend.outputs.tags }}

build-backend:
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v3'
- name: Docker meta backend
id: meta-backend
uses: docker/metadata-action@v4
Expand All @@ -42,17 +62,27 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy Backend
- name: Build Backend
uses: docker/build-push-action@v3
with:
context: '{{defaultContext}}:backend'
push: true
context: './backend'
push: false
tags: ${{ steps.meta-backend.outputs.tags }}
- name: Deploy Frontend
uses: docker/build-push-action@v3

push-images:
runs-on: ubuntu-latest
needs: [build-frontend, build-backend]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
context: '{{defaultContext}}:frontend'
push: true
tags: ${{ steps.meta-frontend.outputs.tags }}
build-args: |
BUILD_ENV=${{ fromJSON(steps.meta-frontend.outputs.json).labels['org.opencontainers.image.version'] == 'beta' && 'beta' || 'production' }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Frontend Image
run: |
docker buildx imagetools create -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_FRONTEND }}:${{ steps.meta-frontend.outputs.tags }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_FRONTEND }}:${{ steps.meta-frontend.outputs.tags }}
- name: Push Backend Image
run: |
docker buildx imagetools create -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_BACKEND }}:${{ steps.meta-backend.outputs.tags }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_BACKEND }}:${{ steps.meta-backend.outputs.tags }}

0 comments on commit a458a66

Please sign in to comment.