mirror of
https://github.com/hexastack/hexabot
synced 2025-04-27 17:51:58 +00:00
build: ci workflow (partial)
This commit is contained in:
parent
1f61e43f58
commit
1be780e8e0
84
.github/workflows/docker.yml
vendored
84
.github/workflows/docker.yml
vendored
@ -2,41 +2,36 @@ name: Build and Push Docker Images
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main"]
|
branches:
|
||||||
workflow_dispatch:
|
- 'main'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
|
||||||
jobs:
|
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:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
|
||||||
- paths-filter
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
@ -44,6 +39,7 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
id: docker_login
|
id: docker_login
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@ -51,44 +47,44 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
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
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./
|
context: ./
|
||||||
|
target: production
|
||||||
file: ./frontend/Dockerfile
|
file: ./frontend/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
target: production
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
tags: hexastack/hexabot-ui:latest
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
- name: Build and push API Docker image
|
- name: Build and push API Docker image
|
||||||
if: ${{ needs.paths-filter.outputs.api == 'true' }}
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./api/
|
context: ./api/
|
||||||
target: production
|
target: production
|
||||||
file: ./api/Dockerfile
|
file: ./api/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: hexastack/hexabot-api:latest
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
- name: Build and push Widget Docker image
|
- name: Build and push Base Docker base image
|
||||||
if: ${{ needs.paths-filter.outputs.widget == 'true' }}
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./widget/
|
context: ./api/
|
||||||
file: ./widget/Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
target: production
|
target: production
|
||||||
push: true
|
file: ./api/Dockerfile.base
|
||||||
tags: hexastack/hexabot-widget:latest
|
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
|
- name: Build and push NLU Docker image
|
||||||
if: ${{ needs.paths-filter.outputs.nlu == 'true' }}
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./nlu/
|
context: ./nlu/
|
||||||
file: ./nlu/Dockerfile
|
file: ./nlu/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: hexastack/hexabot-nlu:latest
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
63
.github/workflows/hexabot-npm.yml
vendored
Normal file
63
.github/workflows/hexabot-npm.yml
vendored
Normal file
@ -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
|
58
.github/workflows/widget-npm.yml
vendored
Normal file
58
.github/workflows/widget-npm.yml
vendored
Normal file
@ -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
|
@ -39,13 +39,7 @@
|
|||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"reset": "npm install && npm run containers:restart",
|
"reset": "npm install && npm run containers:restart",
|
||||||
"reset:hard": "npm clean-install && npm run containers:rebuild",
|
"reset:hard": "npm clean-install && npm run containers:rebuild",
|
||||||
"migrate": "npx ts-migrate-mongoose --config-path ./migrations/config/migrate.ts",
|
"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"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs-modules/mailer": "^1.11.2",
|
"@nestjs-modules/mailer": "^1.11.2",
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"dev:frontend": "npm run dev --workspace=frontend",
|
"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": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^19.3.0",
|
"@commitlint/cli": "^19.3.0",
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
"lint:fix": "eslint . --ext ts,tsx --fix",
|
"lint:fix": "eslint . --ext ts,tsx --fix",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"serve": "npx http-server ./dist/",
|
"serve": "npx http-server ./dist/",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit"
|
||||||
"release": "npm run build && npm version patch && npm publish"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/emoji-js": "^3.5.2",
|
"@types/emoji-js": "^3.5.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user