Repository navigation
53 lines (46 loc) · 1.61 KB
/
Copy pathdocker.yml
File metadata and controls
53 lines (46 loc) · 1.61 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
52
53
# 放到 .github/workflows/docker.yml
# 需要:仓库 Variables 里设 DOCKERHUB_USER;Secrets 里设 DOCKERHUB_TOKEN(Docker Hub Access Token)
name: docker
on:
push:
tags: ["v*"]
workflow_dispatch:
jobs:
image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # 推 GHCR 用
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/${{ vars.DOCKERHUB_USER }}/json-ping
ghcr.io/${{ github.repository_owner }}/json-ping
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ github.ref_name }}
provenance: false # 避免部分平台(如 RouterOS)解析 manifest 时遇到 attestation 条目
cache-from: type=gha
cache-to: type=gha,mode=max