-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aditya Joshi <adityaprakashjoshi1@gmail.com>
- Loading branch information
1 parent
4b46082
commit 192531d
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright the Hyperledger Blockchain Explorer contributors. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Build docker image | ||
|
||
on: | ||
workflow_dispatch: # workflow_dispatch must be enabled in main branch to support release action on older release branches | ||
create: | ||
tags: | ||
- v* | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "Dockerfile" | ||
- "postgres-Dockerfile" | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_PATH: ghcr.io/${{ github.repository_owner }} | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
# on tag vx.y.z created, create docker tag x.y.z | ||
build-and-push-docker-release: | ||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- dockerfile: ./Dockerfile | ||
image: ghcr.io/${{ github.repository_owner }}/explorer | ||
- dockerfile: ./postgres-Dockerfile | ||
image: ghcr.io/${{ github.repository_owner }}/explorer-db | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
buildkitd-flags: --debug | ||
config-inline: | | ||
[worker.oci] | ||
max-parallelism = 1 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ matrix.image }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}}.{{minor}}.{{patch}} | ||
- name: Login to the container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push release tag based on release ${{ steps.meta.outputs.tags }} | ||
id: explorer_release | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ${{ matrix.dockerfile }} | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} |