From b5468f81ee8900b8e448cc50c4ade37472605972 Mon Sep 17 00:00:00 2001 From: Emnaghz Date: Wed, 18 Sep 2024 12:25:56 +0100 Subject: [PATCH 1/3] feat: add merge workflow --- .github/workflows/merge.yml | 111 ++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .github/workflows/merge.yml diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 00000000..bb32564c --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,111 @@ +name: Build and Push Docker Image On Merge +on: + push: + branches: ['main'] + + workflow_dispatch: + +jobs: + paths-filter: + runs-on: ubuntu-latest + outputs: + frontend: ${{ steps.filter.outputs.frontend }} + api: ${{ steps.filter.outputs.api }} + widget: ${{ steps.filter.outputs.widget }} + steps: + - uses: actions/checkout@v4 + - name: Filter paths + id: filter + uses: dorny/paths-filter@v3 + with: + filters: | + frontend: + - 'frontend/**' + api: + - 'api/**' + widget: + - 'widget/**' + + frontend-build-and-push: + runs-on: ubuntu-latest + if: ${{ needs.paths-filter.outputs.frontend == '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 + 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 + 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: ./api + platforms: linux/amd64,linux/arm64 + push: true + tags: hexastack/hexabot-api: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 + uses: docker/build-push-action@v6 + with: + context: ./widget + platforms: linux/amd64,linux/arm64 + push: true + tags: hexastack/hexabot-widget:latest From eb3f53d787140aaed1a4dbfec88bc41d0c33e9a3 Mon Sep 17 00:00:00 2001 From: Emnaghz Date: Thu, 19 Sep 2024 11:25:09 +0100 Subject: [PATCH 2/3] 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 From 3f20a968afa1a916c3ff87bf5000506abf2c70f6 Mon Sep 17 00:00:00 2001 From: Yassine Sallemi Date: Fri, 20 Sep 2024 17:00:52 +0100 Subject: [PATCH 3/3] feat: merge workflow optimized --- .github/workflows/merge.yml | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 56281097..3b8258a2 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -1,8 +1,8 @@ -name: Build and Push Docker Image On Merge +name: Build and Push Docker Images On Merge on: push: - branches: ['main'] + branches: ["main"] workflow_dispatch: jobs: @@ -12,6 +12,7 @@ jobs: frontend: ${{ steps.filter.outputs.frontend }} api: ${{ steps.filter.outputs.api }} widget: ${{ steps.filter.outputs.widget }} + nlu: ${{ steps.filter.outputs.nlu }} steps: - uses: actions/checkout@v4 - name: Filter paths @@ -25,6 +26,8 @@ jobs: - 'api/**' widget: - 'widget/**' + nlu: + - 'nlu/**' build-and-push: runs-on: ubuntu-latest @@ -39,7 +42,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Login to Docker Hub id: docker_login uses: docker/login-action@v2 @@ -47,7 +50,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push frontend Docker image + - name: Build and push Frontend Docker image if: ${{ needs.paths-filter.outputs.frontend == 'true' }} uses: docker/build-push-action@v6 with: @@ -55,24 +58,34 @@ jobs: file: ./frontend/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-frontend:latest + tags: hexastack/hexabot-ui:latest - name: Build and push API Docker image if: ${{ needs.paths-filter.outputs.api == 'true' }} uses: docker/build-push-action@v6 with: - context: ./ + context: ./api/ file: ./api/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-api:latest + tags: hexastack/hexabot-api:latest - - name: Build and push widget Docker image + - name: Build and push Widget Docker image if: ${{ needs.paths-filter.outputs.widget == 'true' }} uses: docker/build-push-action@v6 with: - context: ./ + context: ./widget/ file: ./widget/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-widget:latest + tags: hexastack/hexabot-widget:latest + + - name: Build and push NLU Docker image + if: ${{ needs.paths-filter.outputs.nlu == 'true' }} + uses: docker/build-push-action@v6 + with: + context: ./nlu/ + file: ./nlu/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: hexastack/hexabot-nlu:latest