-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (94 loc) · 2.98 KB
/
docker.yml
File metadata and controls
109 lines (94 loc) · 2.98 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Docker
on:
push:
branches: ["main"]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
env:
REGISTRY: docker.io
# 修改为你的 Docker Hub 用户名
IMAGE_NAME: ${{ vars.DOCKER_USERNAME || 'zmabin' }}/openlist-chunk
jobs:
docker:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Generate tags
id: meta
run: |
TAGS="${{ env.IMAGE_NAME }}:latest"
# If tag push like v1.0.0, also tag with version
if [[ "${{ github.ref }}" =~ ^refs/tags/v ]]; then
VERSION="${{ github.ref_name }}"
TAGS="${TAGS},${{ env.IMAGE_NAME }}:${VERSION}"
# Also tag without v prefix (e.g., 1.0.0)
TAGS="${TAGS},${{ env.IMAGE_NAME }}:${VERSION#v}"
fi
# Tag with short commit SHA
SHORT_SHA="${GITHUB_SHA::7}"
TAGS="${TAGS},${{ env.IMAGE_NAME }}:${SHORT_SHA}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
ghcr:
name: Build and push to ghcr.io
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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.GITHUB_TOKEN }}
- name: Generate tags
id: meta
run: |
IMAGE="ghcr.io/${{ github.repository_owner }}/openlist-chunk"
TAGS="${IMAGE}:latest"
if [[ "${{ github.ref }}" =~ ^refs/tags/v ]]; then
VERSION="${{ github.ref_name }}"
TAGS="${TAGS},${IMAGE}:${VERSION}"
TAGS="${TAGS},${IMAGE}:${VERSION#v}"
fi
SHORT_SHA="${GITHUB_SHA::7}"
TAGS="${TAGS},${IMAGE}:${SHORT_SHA}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max