Skip to content

Commit 02dd28e

Browse files
committed
move to ghcr registry
Signed-off-by: Aditya Joshi <[email protected]>
1 parent 4b46082 commit 02dd28e

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

.github/workflows/release.yaml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Copyright the Hyperledger Blockchain Explorer contributors. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Build docker image
6+
7+
on:
8+
workflow_dispatch: # workflow_dispatch must be enabled in main branch to support release action on older release branches
9+
create:
10+
tags:
11+
- v*
12+
push:
13+
branches:
14+
- main
15+
paths:
16+
- 'Dockerfile'
17+
- 'postgres-Dockerfile'
18+
19+
20+
env:
21+
REGISTRY: ghcr.io
22+
IMAGE_PATH: ghcr.io/${{ github.repository_owner }}
23+
24+
permissions:
25+
contents: read
26+
packages: write
27+
28+
jobs:
29+
# on push to main branch, create docker tags latest
30+
build-and-push-docker-latest:
31+
name: Build and Push docker image with latest tage
32+
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
33+
runs-on: ubuntu-latest
34+
35+
permissions:
36+
contents: read
37+
packages: write
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v1
45+
46+
- name: Set up QEMU
47+
uses: docker/setup-qemu-action@v1
48+
49+
- name: Login to the container registry
50+
uses: docker/login-action@v1
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Lowercase IMAGE_PATH
57+
id: image_path_format
58+
uses: ASzc/change-string-case-action@v2
59+
with:
60+
string: ${{ env.IMAGE_PATH }}
61+
62+
- name: Build and push img with latest tag
63+
id: explorer_latest
64+
uses: docker/build-push-action@v2
65+
with:
66+
context: .
67+
file: ./Dockerfile
68+
push: true
69+
platforms: linux/amd64,linux/arm64,linux/arm/v7
70+
tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer:latest
71+
72+
- name: Build and push img with latest tag
73+
id: explorer-db_latest
74+
uses: docker/build-push-action@v2
75+
with:
76+
context: .
77+
file: ./postgres-Dockerfile
78+
push: true
79+
platforms: linux/amd64,linux/arm64,linux/arm/v7
80+
tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer-db:latest
81+
82+
83+
# on tag vx.y.z created, create docker tag x.y.z
84+
build-and-push-docker-release:
85+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
86+
runs-on: ubuntu-latest
87+
permissions:
88+
contents: read
89+
packages: write
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v2
93+
94+
- name: Set output
95+
id: vars
96+
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/v}
97+
98+
- name: Set up QEMU
99+
uses: docker/setup-qemu-action@v1
100+
101+
- name: Set up Docker Buildx
102+
uses: docker/setup-buildx-action@v1
103+
104+
- name: Login to the container registry
105+
uses: docker/login-action@v1
106+
with:
107+
registry: ${{ env.REGISTRY }}
108+
username: ${{ github.actor }}
109+
password: ${{ secrets.GITHUB_TOKEN }}
110+
111+
- name: Lowercase IMAGE_PATH
112+
id: image_path_format
113+
uses: ASzc/change-string-case-action@v2
114+
with:
115+
string: ${{ env.IMAGE_PATH }}
116+
117+
- name: Build and push release tag based on release ${{ steps.var.outputs.tag }}
118+
id: explorer_db_release
119+
uses: docker/build-push-action@v2
120+
with:
121+
context: .
122+
file: ./postgres-Dockerfile
123+
push: true
124+
platforms: linux/amd64,linux/arm64,linux/arm/v7
125+
tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer-db:${{ steps.vars.outputs.tag }}
126+
127+
- name: Build and push release tag based on release ${{ steps.var.outputs.tag }}
128+
id: explorer_release
129+
uses: docker/build-push-action@v2
130+
with:
131+
context: .
132+
file: ./Dockerfile
133+
push: true
134+
platforms: linux/amd64,linux/arm64,linux/arm/v7
135+
tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer:${{ steps.vars.outputs.tag }}

0 commit comments

Comments
 (0)