File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 99env :
1010 REGISTRY : ghcr.io
1111 IMAGE_NAME : ${{ github.repository }}
12+ DOCKERHUB_REGISTRY : docker.io
13+ DOCKERHUB_IMAGE_NAME : your_dockerhub_username/your_image_name
1214
1315jobs :
1416 build :
@@ -39,13 +41,23 @@ jobs:
3941 username : ${{ github.actor }}
4042 password : ${{ secrets.GITHUB_TOKEN }}
4143
44+ # 登录到 Docker Hub
45+ - name : Log into Docker Hub
46+ if : github.event_name != 'pull_request'
47+ uses : docker/login-action@v3
48+ with :
49+ registry : ${{ env.DOCKERHUB_REGISTRY }}
50+ username : ${{ secrets.DOCKERHUB_USERNAME }}
51+ password : ${{ secrets.DOCKERHUB_TOKEN }}
52+
4253 # 提取 Docker 元数据
4354 - name : Extract Docker metadata
4455 id : meta
4556 uses : docker/metadata-action@v5
4657 with :
4758 images : |
4859 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60+ ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}
4961 tags : |
5062 type=ref,event=branch
5163 type=ref,event=pr
5466 type=sha
5567 type=raw,value=latest,enable={{is_default_branch}}
5668
57- # 构建并推送到 GHCR
69+ # 构建并推送到 GHCR 和 Docker Hub
5870 - name : Build and push Docker image
5971 uses : docker/build-push-action@v5
6072 with :
You can’t perform that action at this time.
0 commit comments