Skip to content

chore: optimize build process #339

chore: optimize build process

chore: optimize build process #339

Workflow file for this run

name: Deployment
on:
push:
tags:
- '2.*'
branches:
- beta
jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v3'
- name: Docker meta frontend
id: meta-frontend
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_FRONTEND }}
tags: |
type=ref,event=branch
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
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_BACKEND }}
tags: |
type=ref,event=branch
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 Backend
uses: docker/build-push-action@v3
with:
context: './backend'
push: false
tags: ${{ steps.meta-backend.outputs.tags }}
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:
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 }}