From eb3f53d787140aaed1a4dbfec88bc41d0c33e9a3 Mon Sep 17 00:00:00 2001 From: Emnaghz Date: Thu, 19 Sep 2024 11:25:09 +0100 Subject: [PATCH] feat: optimize workflow --- .github/workflows/merge.yml | 91 ++++++++++++------------------------- 1 file changed, 29 insertions(+), 62 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index bb32564c..56281097 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -1,8 +1,8 @@ name: Build and Push Docker Image On Merge + on: push: branches: ['main'] - workflow_dispatch: jobs: @@ -21,91 +21,58 @@ jobs: filters: | frontend: - 'frontend/**' - api: + api: - 'api/**' widget: - 'widget/**' - frontend-build-and-push: + build-and-push: runs-on: ubuntu-latest - if: ${{ needs.paths-filter.outputs.frontend == 'true' }} + needs: + - paths-filter steps: - - name: Check out repository code ... + - name: Check out repository code uses: actions/checkout@v4 - + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push docker image - id: docker_build - uses: docker/build-push-action@v6 - with: - context: ./frontend - platforms: linux/amd64,linux/arm64 - push: true - tags: hexastack/hexabot-frontend:latest - - api-build-and-push: - runs-on: ubuntu-latest - if: ${{ needs.paths-filter.outputs.api == 'true' }} - steps: - - name: Check out repository code ... - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub - uses: docker/login-action@v3 + id: docker_login + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push docker image - id: docker_build + - name: Build and push frontend Docker image + if: ${{ needs.paths-filter.outputs.frontend == 'true' }} uses: docker/build-push-action@v6 with: - context: ./api + context: ./ + file: ./frontend/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: hexastack/hexabot-api:latest + tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-frontend:latest - widget-build-and-push: - runs-on: ubuntu-latest - if: ${{ needs.paths-filter.outputs.widget == 'true' }} - steps: - - name: Check out repository code ... - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push docker image - id: docker_build + - name: Build and push API Docker image + if: ${{ needs.paths-filter.outputs.api == 'true' }} uses: docker/build-push-action@v6 with: - context: ./widget + context: ./ + file: ./api/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: hexastack/hexabot-widget:latest + tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-api:latest + + - name: Build and push widget Docker image + if: ${{ needs.paths-filter.outputs.widget == 'true' }} + uses: docker/build-push-action@v6 + with: + context: ./ + file: ./widget/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-widget:latest