Skip to content

Commit 32d6a92

Browse files
bestbeforetodaydenyeart
authored andcommitted
Publish Docker images to GitHub Container Registry
In addition to publishing Docker images to Docker Hub, also publish to GitHub Container Registry. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent b5a9798 commit 32d6a92

File tree

1 file changed

+44
-37
lines changed

1 file changed

+44
-37
lines changed

.github/workflows/release.yml

+44-37
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ env:
1515
GO_VER: 1.23.2
1616
UBUNTU_VER: 22.04
1717
FABRIC_VER: ${{ github.ref_name }}
18-
DOCKER_REGISTRY: ${{ github.repository_owner == 'hyperledger' && 'docker.io' || 'ghcr.io' }}
1918

2019
permissions:
2120
contents: read
@@ -26,22 +25,22 @@ jobs:
2625
strategy:
2726
matrix:
2827
include:
29-
- image: fabric-ubuntu-22.04
30-
target: linux
31-
arch: amd64
32-
- image: fabric-ubuntu-22.04
33-
target: linux
34-
arch: arm64
35-
- image: macos-11
36-
target: darwin
37-
arch: amd64
38-
- image: macos-11
39-
target: darwin
40-
arch: arm64
41-
- image: fabric-windows-latest
42-
target: windows
43-
arch: amd64
44-
runs-on: fabric-ubuntu-22.04
28+
- image: fabric-ubuntu-22.04
29+
target: linux
30+
arch: amd64
31+
- image: fabric-ubuntu-22.04
32+
target: linux
33+
arch: arm64
34+
- image: macos-11
35+
target: darwin
36+
arch: amd64
37+
- image: macos-11
38+
target: darwin
39+
arch: arm64
40+
- image: fabric-windows-latest
41+
target: windows
42+
arch: amd64
43+
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
4544
steps:
4645
- name: Checkout Fabric Code
4746
uses: actions/checkout@v4
@@ -65,62 +64,70 @@ jobs:
6564

6665
build-and-push-docker-images:
6766
name: Build and Push
68-
runs-on: fabric-ubuntu-22.04
67+
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
6968

7069
permissions:
7170
contents: read
7271
packages: write
7372

7473
strategy:
74+
fail-fast: false
7575
matrix:
76-
include:
77-
- COMPONENT: baseos
78-
CONTEXT: images/baseos
79-
- COMPONENT: ccenv
80-
CONTEXT: images/ccenv
81-
- COMPONENT: peer
82-
CONTEXT: .
83-
- COMPONENT: orderer
84-
CONTEXT: .
76+
registry:
77+
- docker.io
78+
- ghcr.io
79+
component:
80+
- name: baseos
81+
context: images/baseos
82+
- name: ccenv
83+
context: images/ccenv
84+
- name: peer
85+
context: .
86+
- name: orderer
87+
context: .
8588

8689
steps:
90+
- name: Skip Docker Hub publish for forks
91+
if: ${{ github.repository_owner != 'hyperledger' && matrix.registry == 'docker.io' }}
92+
run: exit 1
93+
8794
- name: Set up QEMU
8895
uses: docker/setup-qemu-action@v3
8996

9097
- name: Set up Docker Buildx
9198
uses: docker/setup-buildx-action@v3
9299
with:
93100
buildkitd-flags: --debug
94-
config-inline: |
101+
buildkitd-config-inline: |
95102
[worker.oci]
96103
max-parallelism = 1
97104
98105
- name: Checkout
99106
uses: actions/checkout@v4
100107

101-
- name: Login to the ${{ env.DOCKER_REGISTRY }} Container Registry
108+
- name: Login to the ${{ matrix.registry }} Container Registry
102109
uses: docker/login-action@v3
103110
with:
104-
registry: ${{ env.DOCKER_REGISTRY }}
105-
username: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
106-
password: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
111+
registry: ${{ matrix.registry }}
112+
username: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
113+
password: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
107114

108115
- name: Docker meta
109116
id: meta
110117
uses: docker/metadata-action@v5
111118
with:
112-
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-${{ matrix.COMPONENT }}
119+
images: ${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}
113120
tags: |
114121
type=semver,pattern={{version}}
115122
type=semver,pattern={{major}}.{{minor}}
116123
type=semver,pattern={{major}}.{{minor}}.{{patch}}
117124
118-
- name: Build and push ${{ matrix.COMPONENT }} Image
125+
- name: Build and push ${{ matrix.component.name }} Image
119126
id: push
120127
uses: docker/build-push-action@v5
121128
with:
122-
context: ${{ matrix.CONTEXT }}
123-
file: images/${{ matrix.COMPONENT }}/Dockerfile
129+
context: ${{ matrix.component.context }}
130+
file: images/${{ matrix.component.name }}/Dockerfile
124131
platforms: linux/amd64,linux/arm64
125132
tags: ${{ steps.meta.outputs.tags }}
126133
push: ${{ github.event_name != 'pull_request' }}
@@ -136,7 +143,7 @@ jobs:
136143
needs:
137144
- build-binaries
138145
- build-and-push-docker-images
139-
runs-on: fabric-ubuntu-22.04
146+
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
140147
permissions:
141148
contents: write
142149
steps:

0 commit comments

Comments
 (0)