Skip to content

Commit 52e8287

Browse files
committed
修复:GitHub Actions Docker 推送权限问题
- 添加 packages: write 权限 - 修正 Docker 镜像名称大小写问题 - 明确指定镜像推送目标为 ghcr.io/zy84338719/filecodebox
1 parent fb1a0a5 commit 52e8287

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
pull_request:
99
branches: [ main ]
1010

11+
permissions:
12+
contents: read
13+
packages: write
14+
1115
jobs:
1216
build:
1317
name: Build for multiple platforms
@@ -155,7 +159,10 @@ jobs:
155159
name: Build and push Docker image
156160
runs-on: ubuntu-latest
157161
needs: build
158-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
162+
if: startsWith(github.ref, 'refs/tags/')
163+
permissions:
164+
contents: read
165+
packages: write
159166

160167
steps:
161168
- name: Checkout code
@@ -175,14 +182,12 @@ jobs:
175182
id: meta
176183
uses: docker/metadata-action@v5
177184
with:
178-
images: ghcr.io/${{ github.repository }}
185+
images: ghcr.io/zy84338719/filecodebox
179186
tags: |
180187
type=semver,pattern={{version}}
181188
type=semver,pattern={{major}}.{{minor}}
182189
type=semver,pattern={{major}}
183-
type=raw,value=latest,enable={{is_default_branch}}
184-
type=ref,event=branch
185-
type=raw,value=dev,enable={{is_default_branch}}
190+
type=raw,value=latest
186191
labels: |
187192
org.opencontainers.image.title=FileCodeBox
188193
org.opencontainers.image.description=高性能文件分享服务 - Go语言实现
@@ -298,9 +303,9 @@ jobs:
298303
299304
**Docker 镜像:**
300305
\`\`\`bash
301-
docker pull ghcr.io/${{ github.repository }}:${{ github.ref_name }}
306+
docker pull ghcr.io/zy84338719/filecodebox:${{ github.ref_name }}
302307
# 或者最新版本
303-
docker pull ghcr.io/${{ github.repository }}:latest
308+
docker pull ghcr.io/zy84338719/filecodebox:latest
304309
\`\`\`
305310
306311
### 🔧 快速开始

0 commit comments

Comments
 (0)