mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-24 23:29:49 +08:00
feature(ai-service): automatically create docker image when pr merged (#59)
* support the workflow to build nightly image * remove the testing branch * remove the deprecated workflow * release nightly image workflow * remove the testing branch * rename the workflows * manual release image workflow * remove the testing branch * release stable image * remove the testing code --------- Co-authored-by: Chih-Yu Yeh <chihyu.jimmy.yeh@gmail.com>
This commit is contained in:
+16
-30
@@ -1,16 +1,11 @@
|
||||
name: AI Service Build image
|
||||
name: AI Service Release image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
docker_image_tag_name:
|
||||
tag_name:
|
||||
description: Docker image tag name (Optional)
|
||||
type: string
|
||||
is_latest:
|
||||
description: Is latest (Optional)
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
|
||||
defaults:
|
||||
run:
|
||||
@@ -21,6 +16,15 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Prepare tag name
|
||||
id: tag-preparation
|
||||
run: |
|
||||
if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then
|
||||
tag_name=${{ github.event.inputs.tag_name }}
|
||||
else
|
||||
tag_name=commit-$(git log -1 --pretty=%h)
|
||||
fi
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
@@ -31,30 +35,12 @@ jobs:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Prepare tag name
|
||||
id: tag-preparation
|
||||
run: |
|
||||
if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then
|
||||
tag_name=${{ github.event.inputs.docker_image_tag_name }}
|
||||
else
|
||||
tag_name=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')-$(git log -1 --pretty=%h)
|
||||
fi
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT
|
||||
- name: Build and push image
|
||||
env:
|
||||
TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }}
|
||||
run: |
|
||||
if [ ${{ github.event.inputs.is_latest }} == true ]; then
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:$TAG_NAME \
|
||||
--tag ghcr.io/canner/wren-ai-service:latest \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
else
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:$TAG_NAME \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
fi
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:$TAG_NAME \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
@@ -0,0 +1,42 @@
|
||||
name: AI Service Release nightly image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'wren-ai-service/**'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: wren-ai-service
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Prepare tag name
|
||||
id: tag-preparation
|
||||
run: |
|
||||
tag_name=main-$(git log -1 --pretty=%h)
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push image
|
||||
env:
|
||||
TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }}
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:$TAG_NAME \
|
||||
--tag ghcr.io/canner/wren-ai-service:nightly \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
@@ -0,0 +1,61 @@
|
||||
name: AI Service Release stable image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Give a version for this release
|
||||
type: string
|
||||
required: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: wren-ai-service
|
||||
|
||||
jobs:
|
||||
upgrade-ai-service-version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Git
|
||||
run: |
|
||||
git config --global user.email "dev@cannerdata.com"
|
||||
git config --global user.name "stable-release-bot"
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.12
|
||||
- name: Install Poetry
|
||||
uses: abatilo/actions-poetry@v2
|
||||
with:
|
||||
poetry-version: 1.7.1
|
||||
- name: Upgrade AI Service version
|
||||
run: |
|
||||
version=${{ github.event.inputs.version }}
|
||||
poetry version --next-phase $version
|
||||
git add pyproject.toml
|
||||
git commit -m "Upgrade AI Service version to $version"
|
||||
git push
|
||||
build-image:
|
||||
needs: upgrade-ai-service-version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- 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 GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push image
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:${{ github.event.inputs.version }} \
|
||||
--tag ghcr.io/canner/wren-ai-service:latest \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
Reference in New Issue
Block a user