mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-24 23:29:49 +08:00
Chore: Add a optional input to determine whether putting the latest tag on docker image (#30)
This commit is contained in:
@@ -4,8 +4,13 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
docker_image_tag_name:
|
||||
type: string
|
||||
description: Docker image tag name (Optional)
|
||||
type: string
|
||||
is_latest:
|
||||
description: Is latest (Optional)
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
|
||||
defaults:
|
||||
run:
|
||||
@@ -27,19 +32,29 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Prepare tag name
|
||||
id: prepare_tag
|
||||
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 ::set-output name=tag_name::$tag_name
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT
|
||||
- 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:${{ steps.prepare_tag.outputs.tag_name }} \
|
||||
--tag ghcr.io/canner/wren-ai-service:latest \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user