Skip to content

Commit 9b86f68

Browse files
committed
feat: 更新 Docker CI 工作流,添加 GitHub 容器注册表登录和元数据提取步骤
1 parent 9401155 commit 9b86f68

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/docker-image.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ on:
2222

2323
permissions:
2424
contents: read
25+
packages: write
2526

2627
jobs:
2728
build-and-push:
@@ -41,12 +42,30 @@ jobs:
4142
with:
4243
username: ${{ secrets.DOCKERHUB_USERNAME }}
4344
password: ${{ secrets.DOCKERHUB_TOKEN }}
45+
46+
- name: Login to GitHub Container Registry
47+
uses: docker/login-action@v3
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.repository_owner }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Extract metadata for Docker
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: |
58+
e1saps/onebot-github-webhook
59+
ghcr.io/${{ github.repository }}
60+
tags: |
61+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
62+
type=ref,event=tag
63+
type=sha,format=short
4464
4565
- name: Build and push
4666
uses: docker/build-push-action@v5
4767
with:
4868
context: .
4969
push: ${{ github.event_name != 'pull_request' }}
50-
tags: |
51-
e1saps/onebot-github-webhook:latest
52-
${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && format('e1saps/onebot-github-webhook:{0}', github.ref_name) || format('e1saps/onebot-github-webhook:{0}', github.sha) }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)