-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.49 KB
/
docker-build-push.yml
File metadata and controls
51 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Build and Push Docker Image
on:
push:
tags:
- 'v*' # 推送任何 v 开头的 tag 时触发,如 v1.0, v1.1
workflow_dispatch: # 支持手动触发
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF_NAME}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
pythonhuang/juggle-net8:${{ steps.version.outputs.version }}
pythonhuang/juggle-net8:latest
# 多平台支持(可选,移除 linux/arm64 可加快构建速度)
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATE=${{ github.event.repository.updated_at }}
GIT_COMMIT=${{ github.sha }}
- name: Image digest
run: echo "Image pushed with digest ${{ steps.docker_build.outputs.digest }}"