Skip to content

Commit 387f023

Browse files
committed
feat: 完善docker-image.yml
1 parent e513800 commit 387f023

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

.github/workflows/docker-image.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,50 @@ on:
55
push:
66
branches:
77
- master
8+
tags:
9+
- 'v*'
810

911
jobs:
1012
buildx:
1113
runs-on: ubuntu-latest
1214
steps:
1315
- name: Checkout
14-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1517
with:
1618
submodules: true
1719

20+
- name: Extract metadata
21+
id: meta
22+
uses: docker/metadata-action@v5
23+
with:
24+
images: ${{ secrets.DOCKER_USERNAME }}/filecodebox
25+
tags: |
26+
type=ref,event=branch
27+
type=ref,event=pr
28+
type=semver,pattern={{version}}
29+
type=semver,pattern={{major}}.{{minor}}
30+
type=raw,value=beta,enable={{is_default_branch}}
31+
type=raw,value=latest,enable={{is_default_branch}}
32+
1833
- name: Set up QEMU
19-
uses: docker/setup-qemu-action@v2
34+
uses: docker/setup-qemu-action@v3
2035

2136
- name: Set up Docker Buildx
22-
uses: docker/setup-buildx-action@v2
23-
24-
- name: Cache Docker layers
25-
uses: actions/cache@v3
26-
with:
27-
path: /tmp/.buildx-cache
28-
key: ${{ runner.os }}-buildx-${{ github.sha }}
29-
restore-keys: |
30-
${{ runner.os }}-buildx-
37+
uses: docker/setup-buildx-action@v3
3138

3239
- name: Login to DockerHub
33-
uses: docker/login-action@v2
40+
uses: docker/login-action@v3
3441
with:
3542
username: ${{ secrets.DOCKER_USERNAME }}
3643
password: ${{ secrets.DOCKER_PASSWORD }}
3744

3845
- name: Build and push
39-
uses: docker/build-push-action@v4
46+
uses: docker/build-push-action@v5
4047
with:
4148
context: .
4249
platforms: linux/amd64,linux/arm64
4350
push: true
44-
tags: ${{ secrets.DOCKER_USERNAME }}/filecodebox:beta
45-
cache-from: type=local,src=/tmp/.buildx-cache
46-
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
47-
- name: Move cache
48-
run: |
49-
rm -rf /tmp/.buildx-cache
50-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)