Skip to content

Commit

Permalink
Migrate to ghcr.io (#81)
Browse files Browse the repository at this point in the history
Signed-off-by: Zbynek Roubalik <[email protected]>
  • Loading branch information
zroubalik authored Mar 18, 2021
1 parent a8dc37b commit dcca724
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 12 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/master-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}

Expand All @@ -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 -
Expand Down
4 changes: 2 additions & 2 deletions bundle/manifests/keda.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/manifests/bases/keda.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/testing/catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ metadata:
namespace: olm
spec:
sourceType: grpc
image: docker.io/kedacore/keda-olm-operator-index:master
image: ghcr.io/kedacore/keda-olm-operator-index:master

0 comments on commit dcca724

Please sign in to comment.