Skip to content

Commit b051d95

Browse files
authoredNov 23, 2024··
Publish images to GitHub Container Registry (release-2.5) (#5054)
In addition to publishing Docker images to Docker Hub, also publish to GitHub Container Registry. Backport of #5032 Signed-off-by: David Enyeart <enyeart@us.ibm.com>
1 parent 86a8825 commit b051d95

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed
 

‎.github/workflows/release.yml

+43-36
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ env:
1212
GO_VER: 1.23.1
1313
UBUNTU_VER: 20.04
1414
FABRIC_VER: ${{ github.ref_name }}
15-
DOCKER_REGISTRY: ${{ github.repository_owner == 'hyperledger' && 'docker.io' || 'ghcr.io' }}
1615

1716
permissions:
1817
contents: read
@@ -23,21 +22,21 @@ jobs:
2322
strategy:
2423
matrix:
2524
include:
26-
- image: ubuntu-20.04
27-
target: linux
28-
arch: amd64
29-
- image: ubuntu-20.04
30-
target: linux
31-
arch: arm64
32-
- image: macos-11
33-
target: darwin
34-
arch: amd64
35-
- image: macos-11
36-
target: darwin
37-
arch: arm64
38-
- image: windows-2022
39-
target: windows
40-
arch: amd64
25+
- image: ubuntu-20.04
26+
target: linux
27+
arch: amd64
28+
- image: ubuntu-20.04
29+
target: linux
30+
arch: arm64
31+
- image: macos-11
32+
target: darwin
33+
arch: amd64
34+
- image: macos-11
35+
target: darwin
36+
arch: arm64
37+
- image: windows-2022
38+
target: windows
39+
arch: amd64
4140
runs-on: ubuntu-20.04
4241
steps:
4342
- name: Checkout Fabric Code
@@ -69,57 +68,65 @@ jobs:
6968
packages: write
7069

7170
strategy:
71+
fail-fast: false
7272
matrix:
73-
include:
74-
- COMPONENT: baseos
75-
CONTEXT: images/baseos
76-
- COMPONENT: ccenv
77-
CONTEXT: images/ccenv
78-
- COMPONENT: peer
79-
CONTEXT: .
80-
- COMPONENT: orderer
81-
CONTEXT: .
82-
- COMPONENT: tools
83-
CONTEXT: .
73+
registry:
74+
- docker.io
75+
- ghcr.io
76+
component:
77+
- name: baseos
78+
context: images/baseos
79+
- name: ccenv
80+
context: images/ccenv
81+
- name: peer
82+
context: .
83+
- name: orderer
84+
context: .
85+
- name: tools
86+
context: .
8487

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

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

100-
- name: Login to the ${{ env.DOCKER_REGISTRY }} Container Registry
107+
- name: Login to the ${{ matrix.registry }} Container Registry
101108
uses: docker/login-action@v3
102109
with:
103-
registry: ${{ env.DOCKER_REGISTRY }}
104-
username: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
105-
password: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
110+
registry: ${{ matrix.registry }}
111+
username: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
112+
password: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
106113

107114
- name: Docker meta
108115
id: meta
109116
uses: docker/metadata-action@v5
110117
with:
111-
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-${{ matrix.COMPONENT }}
118+
images: ${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}
112119
tags: |
113120
type=semver,pattern={{version}}
114121
type=semver,pattern={{major}}.{{minor}}
115122
type=semver,pattern={{major}}.{{minor}}.{{patch}}
116123
117-
- name: Build and push ${{ matrix.COMPONENT }} Image
124+
- name: Build and push ${{ matrix.component.name }} Image
118125
id: push
119126
uses: docker/build-push-action@v5
120127
with:
121-
context: ${{ matrix.CONTEXT }}
122-
file: images/${{ matrix.COMPONENT }}/Dockerfile
128+
context: ${{ matrix.component.context }}
129+
file: images/${{ matrix.component.name }}/Dockerfile
123130
platforms: linux/amd64,linux/arm64
124131
tags: ${{ steps.meta.outputs.tags }}
125132
push: ${{ github.event_name != 'pull_request' }}

0 commit comments

Comments
 (0)
Please sign in to comment.