Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to ghcr registry #382

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# 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
Comment on lines +12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @adityajoshi12 , As per yesterdays (23Aug2023) discussion on this PR, the image build should be triggered only whenever a new release happens(build-and-push-docker-release).
Please look into this and make changes accordingly. Thanks.

Copy link
Contributor Author

@adityajoshi12 adityajoshi12 Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two flow in this CI, one is(L62) when anything pushed to the main branch container images will be created with the latest tag, while the other flow(L84) will be invoked on the creation of tags and new container images will be created based on the tag

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, as per the first workflow the image gets created whenever the code is pushed to main branch. As per discussion conclusion yesterday, the build image should happen whenever we create a new release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I understood that, but does that mean we will not have images with latest tag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can run the two workflows. With the first workflow, we would have the images with the latest tag and with the second work flow will have the images with the release tag. However the first - workflow shouldn't be triggered on every push to main. @adityajoshi12 @arsulegai @vineeth2328 Please suggest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a seperate branch dev and all the new commit/PR can be merged to that branch (dev) and after sometime we can merge the dev branch to the main branch. And image with tag latest can be build with main branch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree @ArchanaArige , for the time being, let us have a human triggered workflow for the latest tag image creation. Re: Branching strategy, Manoj (mentee) is experimenting something similar and listing down advantages/disadvantages in terms of maintainability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will discuss about this one in the next call and make a decision. There are some other dependency PRs, once they are merged, then we can go ahead and merge this one too.

paths:
- "Dockerfile"
- "postgres-Dockerfile"

env:
REGISTRY: ghcr.io

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
component: explorer
- dockerfile: ./postgres-Dockerfile
component: 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: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.component }}
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 ${{ matrix.component }} Image
id: push
uses: docker/build-push-action@v4
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}