feat: merge workflow optimized

This commit is contained in:
Yassine Sallemi 2024-09-20 17:00:52 +01:00
parent eb3f53d787
commit 3f20a968af

View File

@ -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