From dcca72444147e588ec6e2fa721bb087edb0875af Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com> Date: Thu, 18 Mar 2021 18:17:11 +0100 Subject: [PATCH] Migrate to ghcr.io (#81) Signed-off-by: Zbynek Roubalik --- .github/workflows/master-build.yml | 35 ++++++++++++++++++- .github/workflows/release-build.yml | 17 ++++++++- Makefile | 12 +++++-- .../manifests/keda.clusterserviceversion.yaml | 4 +-- config/manager/kustomization.yaml | 4 +-- config/manager/manager.yaml | 2 +- .../bases/keda.clusterserviceversion.yaml | 4 +-- config/testing/catalog.yaml | 2 +- 8 files changed, 68 insertions(+), 12 deletions(-) diff --git a/.github/workflows/master-build.yml b/.github/workflows/master-build.yml index 98731fc3b..7e9888bc6 100644 --- a/.github/workflows/master-build.yml +++ b/.github/workflows/master-build.yml @@ -29,14 +29,27 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + - name: Login to Docker Hub env: DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} run: echo $DOCKER_HUB_ACCESS_TOKEN | docker login -u $DOCKER_HUB_USERNAME --password-stdin - - name: Publish + - name: Publish on GitHub Container Registry run: make publish + + - name: Publish on Docker Hub + run: make publish-dockerhub deploy-test: needs: Build @@ -54,6 +67,16 @@ jobs: with: go-version: '^1.15.6' + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + - name: Login to Docker Hub env: DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -118,6 +141,16 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + - name: Login to Docker Hub env: DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 3cf69d5f0..b3821ee03 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -26,6 +26,16 @@ jobs: - name: Go modules sync run: go mod tidy + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + - name: Login to Docker Hub env: DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -36,7 +46,12 @@ jobs: id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - - name: Publish KEDA images to Docker Hub + - name: Publish KEDA images on GitHub Container Registry run: make publish env: VERSION: ${{ steps.get_version.outputs.VERSION }} + + - name: Publish KEDA images on Docker Hub + run: make publish-dockerhub + env: + VERSION: ${{ steps.get_version.outputs.VERSION }} diff --git a/Makefile b/Makefile index a75adbe32..ab36bbbc4 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Variables # ################################################## VERSION ?= master -IMAGE_REGISTRY ?= docker.io +IMAGE_REGISTRY ?= ghcr.io IMAGE_REPO ?= kedacore IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-olm-operator:$(VERSION) @@ -31,9 +31,17 @@ all: build ################################################## # PUBLISH # ################################################## +.PHONY: publish publish: docker-build docker-push +# Mirror images on Docker Hub +.PHONY: publish-dockerhub +publish-dockerhub: + docker tag $(IMAGE_CONTROLLER) docker.io/$(IMAGE_REPO)/keda-olm-operator:$(VERSION) + docker push docker.io/$(IMAGE_REPO)/keda-olm-operator:$(VERSION) + # Push the docker image +.PHONY: docker-push docker-push: docker push ${IMAGE_CONTROLLER} @@ -57,7 +65,7 @@ uninstall: manifests kustomize # Deploy controller in the configured Kubernetes cluster in ~/.kube/config deploy: manifests kustomize cd config/manager && \ - $(KUSTOMIZE) edit set image docker.io/kedacore/keda-olm-operator=${IMAGE_CONTROLLER} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-olm-operator=${IMAGE_CONTROLLER} cd config/default && \ $(KUSTOMIZE) edit add label -f app.kubernetes.io/version:${VERSION} $(KUSTOMIZE) build config/default | kubectl apply -f - diff --git a/bundle/manifests/keda.clusterserviceversion.yaml b/bundle/manifests/keda.clusterserviceversion.yaml index eb3369c45..813f2ef9b 100644 --- a/bundle/manifests/keda.clusterserviceversion.yaml +++ b/bundle/manifests/keda.clusterserviceversion.yaml @@ -90,7 +90,7 @@ metadata: capabilities: Seamless Upgrades categories: Cloud Provider certified: "false" - containerImage: docker.io/kedacore/keda-olm-operator:2.0.0 + containerImage: ghcr.io/kedacore/keda-olm-operator:2.2.0 createdAt: 2021-27-01T00:00:00.000Z description: Operator that provides KEDA, a Kubernetes-based event driver autoscaler operatorframework.io/suggested-namespace: keda @@ -465,7 +465,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.annotations['olm.targetNamespaces'] - image: docker.io/zroubalik/keda-olm-operator:master + image: ghcr.io/kedacore/keda-olm-operator:master imagePullPolicy: Always livenessProbe: httpGet: diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index dad4e25ee..4a78f4130 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -3,6 +3,6 @@ resources: apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: -- name: docker.io/kedacore/keda-olm-operator - newName: docker.io/kedacore/keda-olm-operator +- name: ghcr.io/kedacore/keda-olm-operator + newName: ghcr.io/kedacore/keda-olm-operator newTag: master diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 56e4e7495..9d4faf8ab 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -16,7 +16,7 @@ spec: serviceAccountName: keda-olm-operator containers: - name: keda-olm-operator - image: docker.io/kedacore/keda-olm-operator:master + image: ghcr.io/kedacore/keda-olm-operator:master command: - /manager imagePullPolicy: Always diff --git a/config/manifests/bases/keda.clusterserviceversion.yaml b/config/manifests/bases/keda.clusterserviceversion.yaml index 881fe64ad..5ee4866a0 100644 --- a/config/manifests/bases/keda.clusterserviceversion.yaml +++ b/config/manifests/bases/keda.clusterserviceversion.yaml @@ -106,7 +106,7 @@ metadata: capabilities: Seamless Upgrades categories: Cloud Provider certified: "false" - containerImage: docker.io/kedacore/keda-olm-operator:2.0.0 + containerImage: ghcr.io/kedacore/keda-olm-operator:2.2.0 createdAt: 2021-27-01T00:00:00.000Z description: Operator that provides KEDA, a Kubernetes-based event driver autoscaler operatorframework.io/suggested-namespace: keda @@ -486,7 +486,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.annotations['olm.targetNamespaces'] - image: docker.io/kedacore/keda-olm-operator:2.0.0 + image: ghcr.io/kedacore/keda-olm-operator:2.2.0 imagePullPolicy: Always livenessProbe: httpGet: diff --git a/config/testing/catalog.yaml b/config/testing/catalog.yaml index 67b685007..1f9b97cd6 100644 --- a/config/testing/catalog.yaml +++ b/config/testing/catalog.yaml @@ -5,4 +5,4 @@ metadata: namespace: olm spec: sourceType: grpc - image: docker.io/kedacore/keda-olm-operator-index:master \ No newline at end of file + image: ghcr.io/kedacore/keda-olm-operator-index:master \ No newline at end of file