From 1be780e8e0d46519e306ac6422bbcd02c8d90023 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 10:56:49 +0100 Subject: [PATCH 1/7] build: ci workflow (partial) --- .github/workflows/docker.yml | 86 +++++++++++++++---------------- .github/workflows/hexabot-npm.yml | 63 ++++++++++++++++++++++ .github/workflows/widget-npm.yml | 58 +++++++++++++++++++++ api/package.json | 10 +--- package.json | 4 +- widget/package.json | 3 +- 6 files changed, 168 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/hexabot-npm.yml create mode 100644 .github/workflows/widget-npm.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 25c2ebb1..26d18552 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,41 +2,36 @@ name: Build and Push Docker Images on: push: - branches: ["main"] - workflow_dispatch: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' jobs: - paths-filter: - runs-on: ubuntu-latest - outputs: - 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 - id: filter - uses: dorny/paths-filter@v3 - with: - filters: | - frontend: - - 'frontend/**' - api: - - 'api/**' - widget: - - 'widget/**' - nlu: - - 'nlu/**' - build-and-push: runs-on: ubuntu-latest - needs: - - paths-filter steps: - name: Check out repository code uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + hexastack/hexabot-ui + hexastack/hexabot-api + hexastack/hexabot-base + hexastack/hexabot-nlu + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -44,6 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub + if: github.event_name != 'pull_request' id: docker_login uses: docker/login-action@v2 with: @@ -51,44 +47,44 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push Frontend Docker image - if: ${{ needs.paths-filter.outputs.frontend == 'true' }} uses: docker/build-push-action@v6 with: context: ./ + target: production file: ./frontend/Dockerfile platforms: linux/amd64,linux/arm64 - push: true - target: production - tags: hexastack/hexabot-ui:latest + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - name: Build and push API Docker image - if: ${{ needs.paths-filter.outputs.api == 'true' }} uses: docker/build-push-action@v6 with: context: ./api/ target: production file: ./api/Dockerfile platforms: linux/amd64,linux/arm64 - push: true - tags: hexastack/hexabot-api:latest - - - name: Build and push Widget Docker image - if: ${{ needs.paths-filter.outputs.widget == 'true' }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Base Docker base image uses: docker/build-push-action@v6 with: - context: ./widget/ - file: ./widget/Dockerfile - platforms: linux/amd64,linux/arm64 + context: ./api/ target: production - push: true - tags: hexastack/hexabot-widget:latest + file: ./api/Dockerfile.base + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - 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 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/hexabot-npm.yml b/.github/workflows/hexabot-npm.yml new file mode 100644 index 00000000..7860372a --- /dev/null +++ b/.github/workflows/hexabot-npm.yml @@ -0,0 +1,63 @@ +name: Publish Hexabot (API Typescript) NPM Package + +on: + push: + tags: + - 'v*' + workflow_dispatch: # Allow manual trigger + +jobs: + publish-package: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Ensure it matches your project requirements + cache: 'npm' + + - name: Navigate to API Folder + run: cd api/ + + - name: Install dependencies + run: npm ci + + - name: Build the package + run: npm run build + + - name: Determine release type + id: determine-release + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then + echo "release=minor" >> $GITHUB_ENV + elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "release=patch" >> $GITHUB_ENV + else + echo "release=none" >> $GITHUB_ENV + fi + else + echo "release=none" >> $GITHUB_ENV + fi + + - name: Login to npm + if: env.release != 'none' + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org/' + node-version: '18' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + if: env.release != 'none' + run: | + if [[ "$release" == "patch" ]]; then + npm run release:patch + elif [[ "$release" == "minor" ]]; then + npm run release:minor + fi diff --git a/.github/workflows/widget-npm.yml b/.github/workflows/widget-npm.yml new file mode 100644 index 00000000..c3765784 --- /dev/null +++ b/.github/workflows/widget-npm.yml @@ -0,0 +1,58 @@ +name: Publish Hexabot Widget NPM Package + +on: + push: + tags: + - 'v*' + workflow_dispatch: # Allow manual trigger + +jobs: + publish-package: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Ensure it matches your project requirements + cache: 'npm' + + - name: Navigate to Widget Folder + run: cd widget/ + + - name: Install dependencies + run: npm ci + + - name: Build the package + run: npm run build + + - name: Determine release type + id: determine-release + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then + echo "release=minor" >> $GITHUB_ENV + elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "release=patch" >> $GITHUB_ENV + else + echo "release=none" >> $GITHUB_ENV + fi + else + echo "release=none" >> $GITHUB_ENV + fi + + - name: Login to npm + if: env.release != 'none' + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org/' + node-version: '18' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + if: env.release != 'none' + run: npm publish diff --git a/api/package.json b/api/package.json index 41e88d9c..720bd778 100644 --- a/api/package.json +++ b/api/package.json @@ -39,13 +39,7 @@ "typecheck": "tsc --noEmit", "reset": "npm install && npm run containers:restart", "reset:hard": "npm clean-install && npm run containers:rebuild", - "migrate": "npx ts-migrate-mongoose --config-path ./migrations/config/migrate.ts", - "docker:build-base": "docker build --pull --rm -f Dockerfile.base -t hexabot-base:latest .", - "docker:tag-base": "docker tag hexabot-base:latest hexastack/hexabot-base:latest", - "docker:push-base": "docker push hexastack/hexabot-base:latest", - "docker:release-base": "npm run docker:build-base && npm run docker:tag-base && npm run docker:push-base", - "npm:release": "npm version patch && npm publish", - "release": "npm run build && npm run npm:release && npm run docker:release-base" + "migrate": "npx ts-migrate-mongoose --config-path ./migrations/config/migrate.ts" }, "dependencies": { "@nestjs-modules/mailer": "^1.11.2", @@ -178,4 +172,4 @@ "@/(.*)": "/$1" } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index bb74c01a..5b22bec6 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "scripts": { "prepare": "husky install", "dev:frontend": "npm run dev --workspace=frontend", - "dev:widget": "npm run dev --workspace=widget" + "dev:widget": "npm run dev --workspace=widget", + "release:api:patch": "npm version patch --workspace=api --workspace=frontend --workspace=widget && git push origin main --tags", + "release:api:minor": "npm version minor --workspace=api --workspace=frontend --workspace=widget && git push origin main --tags" }, "devDependencies": { "@commitlint/cli": "^19.3.0", diff --git a/widget/package.json b/widget/package.json index 8fac6ff7..63e55560 100644 --- a/widget/package.json +++ b/widget/package.json @@ -14,8 +14,7 @@ "lint:fix": "eslint . --ext ts,tsx --fix", "preview": "vite preview", "serve": "npx http-server ./dist/", - "typecheck": "tsc --noEmit", - "release": "npm run build && npm version patch && npm publish" + "typecheck": "tsc --noEmit" }, "dependencies": { "@types/emoji-js": "^3.5.2", From 840cb2fef34f879df31262502ad5cc69a5c640a4 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 11:10:26 +0100 Subject: [PATCH 2/7] build: root level release --- frontend/package.json | 2 +- package.json | 8 +++++--- widget/package.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index b32bec32..08178918 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "hexabot-ui", "private": true, - "version": "2.0.0", + "version": "2.0.17", "description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.", "author": "Hexastack", "license": "AGPL-3.0-only", diff --git a/package.json b/package.json index 5b22bec6..8ecdaefb 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "frontend", "widget" ], - "version": "2.0.0", + "version": "2.0.17", "description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.", "author": "Hexastack", "license": "AGPL-3.0-only", @@ -13,8 +13,10 @@ "prepare": "husky install", "dev:frontend": "npm run dev --workspace=frontend", "dev:widget": "npm run dev --workspace=widget", - "release:api:patch": "npm version patch --workspace=api --workspace=frontend --workspace=widget && git push origin main --tags", - "release:api:minor": "npm version minor --workspace=api --workspace=frontend --workspace=widget && git push origin main --tags" + "release:api:patch": "cd api/ && npm version --git-tag-version false --commit-hooks false patch", + "release:api:minor": "cd api/ && npm version --git-tag-version false --commit-hooks false minor", + "release:patch": "npm run release:api:patch && npm version patch --workspaces && git push origin main --tags", + "release:minor": "npm run release:api:minor && npm version minor --workspaces && git push origin main --tags" }, "devDependencies": { "@commitlint/cli": "^19.3.0", diff --git a/widget/package.json b/widget/package.json index 63e55560..62d806f9 100644 --- a/widget/package.json +++ b/widget/package.json @@ -1,6 +1,6 @@ { "name": "hexabot-chat-widget", - "version": "2.0.3", + "version": "2.0.17", "description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.", "author": "Hexastack", "license": "AGPL-3.0-only", From 21b3c54d422e64751c4eda9a7b573a94dd945aa5 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 11:47:04 +0100 Subject: [PATCH 3/7] build: establish global ci --- .github/workflows/hexabot-npm.yml | 7 +---- bump-version.sh | 49 +++++++++++++++++++++++++++++++ frontend/.dockerignore | 1 + package-lock.json | 8 ++--- package.json | 4 +-- 5 files changed, 57 insertions(+), 12 deletions(-) create mode 100755 bump-version.sh diff --git a/.github/workflows/hexabot-npm.yml b/.github/workflows/hexabot-npm.yml index 7860372a..e7d16237 100644 --- a/.github/workflows/hexabot-npm.yml +++ b/.github/workflows/hexabot-npm.yml @@ -55,9 +55,4 @@ jobs: - name: Publish to npm if: env.release != 'none' - run: | - if [[ "$release" == "patch" ]]; then - npm run release:patch - elif [[ "$release" == "minor" ]]; then - npm run release:minor - fi + run: npm publish diff --git a/bump-version.sh b/bump-version.sh new file mode 100755 index 00000000..194a0085 --- /dev/null +++ b/bump-version.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Ensure script exits on any command failure +set -e + +# Check if a release type argument is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + echo "release-type: patch | minor" + exit 1 +fi + +RELEASE_TYPE=$1 +ROOT_DIR=$(pwd) + +if [[ "$RELEASE_TYPE" != "patch" && "$RELEASE_TYPE" != "minor" ]]; then + echo "Invalid release type. Use 'patch' or 'minor'." + exit 1 +fi + +echo "Executing release: $RELEASE_TYPE" + +# Execute the appropriate npm release command +if [[ "$RELEASE_TYPE" == "patch" ]]; then + npm run release:patch +elif [[ "$RELEASE_TYPE" == "minor" ]]; then + npm run release:minor +fi + +# Retrieve the new version from package.json +NEW_VERSION=$(jq -r '.version' "$ROOT_DIR/package.json") + +if [ -z "$NEW_VERSION" ]; then + echo "Failed to retrieve the version from package.json." + exit 1 +fi + + +# Commit and push changes +echo "Committing and pushing changes..." +git add . +git commit -m "build: v$NEW_VERSION" + +# Add git tag +echo "Tagging version v$NEW_VERSION" +git tag "v$NEW_VERSION" +git push origin main --tags + +echo "Release ($RELEASE_TYPE) completed successfully." diff --git a/frontend/.dockerignore b/frontend/.dockerignore index b6b7a04f..6b9e549c 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -11,3 +11,4 @@ LICENSE .next *.swp /scripts +*.sh diff --git a/package-lock.json b/package-lock.json index b4d808c9..fd9dbbdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hexabot", - "version": "2.0.0", + "version": "2.0.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hexabot", - "version": "2.0.0", + "version": "2.0.17", "license": "AGPL-3.0-only", "workspaces": [ "frontend", @@ -45,7 +45,7 @@ }, "frontend": { "name": "hexabot-ui", - "version": "2.0.0", + "version": "2.0.18", "license": "AGPL-3.0-only", "dependencies": { "@chatscope/chat-ui-kit-react": "^2.0.3", @@ -9771,7 +9771,7 @@ }, "widget": { "name": "hexabot-chat-widget", - "version": "2.0.3", + "version": "2.0.18", "license": "AGPL-3.0-only", "dependencies": { "@types/emoji-js": "^3.5.2", diff --git a/package.json b/package.json index 8ecdaefb..46cefdfa 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "dev:widget": "npm run dev --workspace=widget", "release:api:patch": "cd api/ && npm version --git-tag-version false --commit-hooks false patch", "release:api:minor": "cd api/ && npm version --git-tag-version false --commit-hooks false minor", - "release:patch": "npm run release:api:patch && npm version patch --workspaces && git push origin main --tags", - "release:minor": "npm run release:api:minor && npm version minor --workspaces && git push origin main --tags" + "release:patch": "npm run release:api:patch && npm version --git-tag-version false --commit-hooks false --workspaces patch", + "release:minor": "npm run release:api:minor && npm version --git-tag-version false --commit-hooks false --workspaces minor" }, "devDependencies": { "@commitlint/cli": "^19.3.0", From 93ad05f67630fe13d08db90cda8fb5a224399b96 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 12:05:22 +0100 Subject: [PATCH 4/7] fix: update github actions --- .github/workflows/docker-api.yml | 54 +++++++++++++++++++ .../workflows/{docker.yml => docker-base.yml} | 38 +------------ .github/workflows/docker-nlu.yml | 53 ++++++++++++++++++ .github/workflows/docker-ui.yml | 54 +++++++++++++++++++ 4 files changed, 162 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/docker-api.yml rename .github/workflows/{docker.yml => docker-base.yml} (51%) create mode 100644 .github/workflows/docker-nlu.yml create mode 100644 .github/workflows/docker-ui.yml diff --git a/.github/workflows/docker-api.yml b/.github/workflows/docker-api.yml new file mode 100644 index 00000000..213fddd0 --- /dev/null +++ b/.github/workflows/docker-api.yml @@ -0,0 +1,54 @@ +name: Build and Push Docker API Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-api + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - 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 + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push API Docker image + uses: docker/build-push-action@v6 + with: + context: ./api/ + target: production + file: ./api/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker-base.yml similarity index 51% rename from .github/workflows/docker.yml rename to .github/workflows/docker-base.yml index 26d18552..9e575967 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker-base.yml @@ -21,11 +21,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: | - hexastack/hexabot-ui - hexastack/hexabot-api - hexastack/hexabot-base - hexastack/hexabot-nlu + images: hexastack/hexabot-base tags: | type=ref,event=branch type=ref,event=pr @@ -46,28 +42,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Frontend Docker image - uses: docker/build-push-action@v6 - with: - context: ./ - target: production - file: ./frontend/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push API Docker image - uses: docker/build-push-action@v6 - with: - context: ./api/ - target: production - file: ./api/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Build and push Base Docker base image uses: docker/build-push-action@v6 with: @@ -78,13 +52,3 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push NLU Docker image - uses: docker/build-push-action@v6 - with: - context: ./nlu/ - file: ./nlu/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-nlu.yml b/.github/workflows/docker-nlu.yml new file mode 100644 index 00000000..b8ebd5ae --- /dev/null +++ b/.github/workflows/docker-nlu.yml @@ -0,0 +1,53 @@ +name: Build and Push Docker NLU Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-nlu + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - 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 + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push NLU Docker image + uses: docker/build-push-action@v6 + with: + context: ./nlu/ + file: ./nlu/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-ui.yml b/.github/workflows/docker-ui.yml new file mode 100644 index 00000000..914936ec --- /dev/null +++ b/.github/workflows/docker-ui.yml @@ -0,0 +1,54 @@ +name: Build and Push Docker UI Image + +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: hexastack/hexabot-ui + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - 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 + if: github.event_name != 'pull_request' + id: docker_login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Frontend Docker image + uses: docker/build-push-action@v6 + with: + context: ./ + target: production + file: ./frontend/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 4c58f55838288159e579d48ece8c01171eb1a84e Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 12:06:36 +0100 Subject: [PATCH 5/7] fix: update github actions --- .github/workflows/docker-base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-base.yml b/.github/workflows/docker-base.yml index 9e575967..67d87790 100644 --- a/.github/workflows/docker-base.yml +++ b/.github/workflows/docker-base.yml @@ -1,4 +1,4 @@ -name: Build and Push Docker Images +name: Build and Push Docker Base Image on: push: From 46d1f6cc0dd60acd0c49e8d86ead981de62a9b79 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 12:10:49 +0100 Subject: [PATCH 6/7] fix: remove target --- .github/workflows/docker-base.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-base.yml b/.github/workflows/docker-base.yml index 67d87790..281d2002 100644 --- a/.github/workflows/docker-base.yml +++ b/.github/workflows/docker-base.yml @@ -46,7 +46,6 @@ jobs: uses: docker/build-push-action@v6 with: context: ./api/ - target: production file: ./api/Dockerfile.base platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} From 8dcc9b9813386ecfa355dbf6e0274d7955b190e8 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Tue, 10 Dec 2024 12:27:05 +0100 Subject: [PATCH 7/7] fix: remove docker build on PR --- .github/workflows/docker-api.yml | 3 --- .github/workflows/docker-base.yml | 3 --- .github/workflows/docker-nlu.yml | 3 --- .github/workflows/docker-ui.yml | 3 --- 4 files changed, 12 deletions(-) diff --git a/.github/workflows/docker-api.yml b/.github/workflows/docker-api.yml index 213fddd0..f6638af8 100644 --- a/.github/workflows/docker-api.yml +++ b/.github/workflows/docker-api.yml @@ -6,9 +6,6 @@ on: - 'main' tags: - 'v*' - pull_request: - branches: - - 'main' jobs: build-and-push: diff --git a/.github/workflows/docker-base.yml b/.github/workflows/docker-base.yml index 281d2002..72c29775 100644 --- a/.github/workflows/docker-base.yml +++ b/.github/workflows/docker-base.yml @@ -6,9 +6,6 @@ on: - 'main' tags: - 'v*' - pull_request: - branches: - - 'main' jobs: build-and-push: diff --git a/.github/workflows/docker-nlu.yml b/.github/workflows/docker-nlu.yml index b8ebd5ae..df28941c 100644 --- a/.github/workflows/docker-nlu.yml +++ b/.github/workflows/docker-nlu.yml @@ -6,9 +6,6 @@ on: - 'main' tags: - 'v*' - pull_request: - branches: - - 'main' jobs: build-and-push: diff --git a/.github/workflows/docker-ui.yml b/.github/workflows/docker-ui.yml index 914936ec..2de6939a 100644 --- a/.github/workflows/docker-ui.yml +++ b/.github/workflows/docker-ui.yml @@ -6,9 +6,6 @@ on: - 'main' tags: - 'v*' - pull_request: - branches: - - 'main' jobs: build-and-push: