mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
ci(docker): 精简 Docker 镜像构建流程- 移除了版本号相关逻辑,改为使用当前日期作为标签- 删除了 manager-web 镜像的构建步骤
-简化了工作流触发条件,仅保留 push 和手动触发 - 优化了 Docker 资源清理和登录步骤
This commit is contained in:
parent
5ca83b2558
commit
4d1a03ea86
1 changed files with 5 additions and 35 deletions
40
.github/workflows/docker-image.yml
vendored
40
.github/workflows/docker-image.yml
vendored
|
|
@ -1,11 +1,7 @@
|
|||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*' # 只在以 v 开头的标签推送时触发,例如 v1.0.0
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release Docker images
|
||||
|
|
@ -20,54 +16,28 @@ jobs:
|
|||
run: |
|
||||
df -h
|
||||
docker system df
|
||||
|
||||
- name: Clean up Docker resources
|
||||
run: |
|
||||
docker system prune -af
|
||||
docker builder prune -af
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- 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.TOKEN }}
|
||||
|
||||
- name: Extract version from tag
|
||||
id: get_version
|
||||
run: |
|
||||
if [[ "$GITHUB_REF" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||
echo "VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
|
||||
echo "IS_VERSION=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "VERSION=latest" >> $GITHUB_ENV
|
||||
echo "IS_VERSION=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# 构建 xiaozhi-server 镜像
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "date=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
|
||||
- name: Build and push xiaozhi-server
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile-server
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.IS_VERSION == 'true' && format('ghcr.io/{0}:server_{1}\nghcr.io/{0}:server_latest', github.repository, env.VERSION) || format('ghcr.io/{0}:server_latest', github.repository) }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
# 构建 manager-api 镜像
|
||||
- name: Build and push manager-web
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile-web
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.IS_VERSION == 'true' && format('ghcr.io/{0}:web_{1}\nghcr.io/{0}:web_latest', github.repository, env.VERSION) || format('ghcr.io/{0}:web_latest', github.repository) }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ghcr.io/${{ github.repository_owner }}/xiaozhi-server:${{ steps.date.outputs.date }}
|
||||
platforms: linux/arm64
|
||||
Loading…
Reference in a new issue