Skip to content

Commit f6f9b6c

Browse files
committed
add:添加自动编译
1 parent 8a74f09 commit f6f9b6c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # 只在以 v 开头的标签推送时触发,例如 v1.0.0
7+
workflow_dispatch:
8+
9+
jobs:
10+
release:
11+
name: Release Docker images
12+
runs-on: ubuntu-latest
13+
permissions:
14+
packages: write
15+
contents: write
16+
id-token: write
17+
issues: write
18+
steps:
19+
- name: Check Disk Space
20+
run: |
21+
df -h
22+
docker system df
23+
24+
- name: Clean up Docker resources
25+
run: |
26+
docker system prune -af
27+
docker builder prune -af
28+
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.TOKEN }}
41+
42+
- name: Extract version from tag
43+
id: get_version
44+
run: |
45+
if [[ "$GITHUB_REF" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
46+
echo "VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
47+
echo "IS_VERSION=true" >> $GITHUB_ENV
48+
else
49+
echo "VERSION=latest" >> $GITHUB_ENV
50+
echo "IS_VERSION=false" >> $GITHUB_ENV
51+
fi
52+
53+
# 构建 VOICEPRINT API 镜像
54+
- name: Build and push voiceprint-api
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
file: Dockerfile
59+
push: true
60+
tags: |
61+
${{ env.IS_VERSION == 'true' && format('ghcr.io/{0}:{1},ghcr.io/{0}:latest', github.repository, env.VERSION) || format('ghcr.io/{0}:latest', github.repository) }}
62+
platforms: linux/amd64,linux/arm64

0 commit comments

Comments
 (0)