Skip to content

Commit 0eef8ef

Browse files
committed
Split Docker builds: GHCR first, then Docker Hub separately
1 parent 6fddd0a commit 0eef8ef

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

.github/workflows/docker-publish.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ on:
1313
types: [published]
1414
workflow_dispatch: # Allow manual trigger
1515

16-
env:
17-
GHCR_IMAGE: ghcr.io/${{ github.repository }}
18-
DOCKERHUB_IMAGE: ambsd/heartmula-studio
19-
2016
jobs:
21-
build-and-push:
17+
build-and-push-ghcr:
2218
runs-on: ubuntu-latest
2319
permissions:
2420
contents: read
@@ -38,32 +34,58 @@ jobs:
3834
username: ${{ github.actor }}
3935
password: ${{ secrets.GITHUB_TOKEN }}
4036

37+
- name: Extract metadata
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ghcr.io/${{ github.repository }}
42+
tags: |
43+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
44+
type=semver,pattern={{version}}
45+
type=sha,prefix=
46+
47+
- name: Build and push to GHCR
48+
uses: docker/build-push-action@v5
49+
with:
50+
context: .
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
57+
build-and-push-dockerhub:
58+
runs-on: ubuntu-latest
59+
needs: build-and-push-ghcr # Run after GHCR succeeds
60+
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
4168
- name: Log in to Docker Hub
4269
uses: docker/login-action@v3
4370
with:
4471
username: ${{ secrets.DOCKERHUB_USERNAME }}
4572
password: ${{ secrets.DOCKERHUB_TOKEN }}
4673

47-
- name: Extract metadata (tags, labels)
74+
- name: Extract metadata
4875
id: meta
4976
uses: docker/metadata-action@v5
5077
with:
51-
images: |
52-
${{ env.GHCR_IMAGE }}
53-
${{ env.DOCKERHUB_IMAGE }}
78+
images: ambsd/heartmula-studio
5479
tags: |
5580
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
5681
type=semver,pattern={{version}}
57-
type=semver,pattern={{major}}.{{minor}}
5882
type=sha,prefix=
5983
60-
- name: Build and push Docker image
84+
- name: Build and push to Docker Hub
6185
uses: docker/build-push-action@v5
6286
with:
6387
context: .
6488
push: true
6589
tags: ${{ steps.meta.outputs.tags }}
6690
labels: ${{ steps.meta.outputs.labels }}
6791
cache-from: type=gha
68-
cache-to: type=gha,mode=max
69-
platforms: linux/amd64

0 commit comments

Comments
 (0)