From eb4a39eb81d9226ff57bf3a42dead3f98d18237f Mon Sep 17 00:00:00 2001 From: Aditya Joshi Date: Sun, 16 Apr 2023 18:39:01 +0530 Subject: [PATCH] move to ghcr registry Signed-off-by: Aditya Joshi --- .github/workflows/release.yaml | 133 +++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..b52a2568e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,133 @@ +# 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 push to main branch, create docker tags latest + build-and-push-docker-latest: + name: Build and Push docker image with latest tage + if: ${{ startsWith(github.ref, 'refs/heads/main') }} + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Login to the container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Lowercase IMAGE_PATH + id: image_path_format + uses: ASzc/change-string-case-action@v2 + with: + string: ${{ env.IMAGE_PATH }} + + - name: Build and push img with latest tag + id: explorer_latest + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer:latest + platforms: linux/amd64, linux/arm64, linux/arm/v7, darwin/amd64, darwin/arm64 + + - name: Build and push img with latest tag + id: explorer-db_latest + uses: docker/build-push-action@v2 + with: + context: . + file: ./postgres-Dockerfile + push: true + tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer-db:latest + platforms: linux/amd64, linux/arm64, linux/arm/v7, darwin/amd64, darwin/arm64 + + + # 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 + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set output + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/v} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to the container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Lowercase IMAGE_PATH + id: image_path_format + uses: ASzc/change-string-case-action@v2 + with: + string: ${{ env.IMAGE_PATH }} + + - name: Build and push release tag based on release ${{ steps.var.outputs.tag }} + id: explorer_db_release + uses: docker/build-push-action@v2 + with: + context: . + file: ./postgres-Dockerfile + push: true + tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer-db:${{ steps.vars.outputs.tag }} + + - name: Build and push release tag based on release ${{ steps.var.outputs.tag }} + id: explorer_release + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.image_path_format.outputs.lowercase }}/explorer:${{ steps.vars.outputs.tag }}