-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add build images CI job #32
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,142 @@ | ||
name: Build Images | ||
|
||
on: | ||
push: | ||
branches: [ '*' ] | ||
tags: [ '*' ] | ||
|
||
env: | ||
IMG_TAGS: ${{ github.ref_name }} | ||
IMG_REGISTRY_HOST: quay.io | ||
IMG_REGISTRY_ORG: kuadrant | ||
MAIN_BRANCH_NAME: main | ||
OPERATOR_NAME: authorino-operator | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Add latest tag | ||
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | ||
id: add-latest-tag | ||
run: | | ||
echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV | ||
- name: Build Image | ||
id: build-image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: ${{ env.OPERATOR_NAME }} | ||
tags: ${{ env.IMG_TAGS }} | ||
dockerfiles: | | ||
./Dockerfile | ||
- name: Push Image | ||
if: ${{ !env.ACT }} | ||
id: push-to-quay | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
tags: ${{ steps.build-image.outputs.tags }} | ||
registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} | ||
username: ${{ secrets.IMG_REGISTRY_USERNAME }} | ||
password: ${{ secrets.IMG_REGISTRY_TOKEN }} | ||
- name: Print Image URL | ||
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" | ||
|
||
build-bundle: | ||
needs: build | ||
name: Build Bundle | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.16.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
id: go | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Add latest tag | ||
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | ||
id: add-latest-tag | ||
run: | | ||
echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV | ||
- name: Run make bundle | ||
if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} | ||
run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=${{ github.ref_name }} | ||
- name: Run make bundle (main) | ||
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | ||
run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=latest VERSION=0.0.0 | ||
- name: Git diff | ||
run: git diff | ||
# Uncomment this when ORG in the Makefile to be updated to "kuadrant" | ||
# - name: Verify manifests and bundle | ||
# if: startsWith(github.ref, 'refs/tags/v') || github.ref_name == env.MAIN_BRANCH_NAME | ||
# run: make verify-manifests verify-bundle | ||
- name: Build Image | ||
id: build-image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: ${{ env.OPERATOR_NAME }}-bundle | ||
tags: ${{ env.IMG_TAGS }} | ||
dockerfiles: | | ||
./bundle.Dockerfile | ||
- name: Push Image | ||
if: ${{ !env.ACT }} | ||
id: push-to-quay | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
tags: ${{ steps.build-image.outputs.tags }} | ||
registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} | ||
username: ${{ secrets.IMG_REGISTRY_USERNAME }} | ||
password: ${{ secrets.IMG_REGISTRY_TOKEN }} | ||
- name: Print Image URL | ||
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" | ||
|
||
build-catalog: | ||
name: Build Catalog | ||
needs: [build, build-bundle] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.16.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
id: go | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Add latest tag | ||
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | ||
id: add-latest-tag | ||
run: | | ||
echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV | ||
- name: Run make catalog-generate | ||
if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} | ||
run: make catalog-generate REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=${{ github.ref_name }} | ||
- name: Run make catalog-generate (main) | ||
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} | ||
run: make catalog-generate REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=latest VERSION=0.0.0 | ||
- name: Git diff | ||
run: git diff | ||
- name: Build Image | ||
id: build-image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: ${{ env.OPERATOR_NAME }}-catalog | ||
tags: ${{ env.IMG_TAGS }} | ||
dockerfiles: | | ||
./index.Dockerfile | ||
- name: Push Image | ||
if: ${{ !env.ACT }} | ||
id: push-to-quay | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
tags: ${{ steps.build-image.outputs.tags }} | ||
registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} | ||
username: ${{ secrets.IMG_REGISTRY_USERNAME }} | ||
password: ${{ secrets.IMG_REGISTRY_TOKEN }} | ||
- name: Print Image URL | ||
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" |
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 |
---|---|---|
@@ -1,11 +1,5 @@ | ||
# VERSION defines the project version for the bundle. | ||
OPERATOR_VERSION ?= latest | ||
|
||
ifeq (latest,$(OPERATOR_VERSION)) | ||
OPERATOR_TAG = latest | ||
else | ||
OPERATOR_TAG = v$(OPERATOR_VERSION) | ||
endif | ||
VERSION ?= 0.0.0 | ||
|
||
# Address of the container registry | ||
REGISTRY = quay.io | ||
|
@@ -16,13 +10,19 @@ ORG ?= 3scale | |
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. | ||
IMAGE_TAG_BASE ?= $(REGISTRY)/$(ORG)/authorino-operator | ||
|
||
ifeq (0.0.0,$(VERSION)) | ||
IMAGE_TAG ?= latest | ||
else | ||
IMAGE_TAG ?= v$(VERSION) | ||
endif | ||
|
||
# Image URL to use all building/pushing image targets | ||
DEFAULT_OPERATOR_IMAGE = $(IMAGE_TAG_BASE):$(OPERATOR_TAG) | ||
DEFAULT_OPERATOR_IMAGE = $(IMAGE_TAG_BASE):$(IMAGE_TAG) | ||
OPERATOR_IMAGE ?= $(DEFAULT_OPERATOR_IMAGE) | ||
|
||
# BUNDLE_IMG defines the image:tag used for the bundle. | ||
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>) | ||
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(OPERATOR_TAG) | ||
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(IMAGE_TAG) | ||
|
||
# CHANNELS define the bundle channels used in the bundle. | ||
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") | ||
|
@@ -59,6 +59,13 @@ endif | |
SHELL = /usr/bin/env bash -o pipefail | ||
.SHELLFLAGS = -ec | ||
|
||
AUTHORINO_VERSION ?= latest | ||
ifeq (latest,$(AUTHORINO_VERSION)) | ||
AUTHORINO_BRANCH = main | ||
else | ||
AUTHORINO_BRANCH = v$(AUTHORINO_VERSION) | ||
endif | ||
|
||
all: build | ||
|
||
##@ General | ||
|
@@ -68,10 +75,17 @@ help: ## Display this help. | |
|
||
##@ Development | ||
|
||
manifests: controller-gen kustomize ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
manifests: controller-gen kustomize authorino-manifests ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases && $(KUSTOMIZE) build config/install > $(OPERATOR_MANIFESTS) | ||
$(MAKE) deploy-manifest OPERATOR_IMAGE=$(OPERATOR_IMAGE) | ||
|
||
.PHONY: authorino-manifests | ||
authorino-manifests: export AUTHORINO_GITREF := $(AUTHORINO_BRANCH) | ||
authorino-manifests: ## Update authorino manifests. | ||
envsubst \ | ||
< config/authorino/kustomization.template.yaml \ | ||
> config/authorino/kustomization.yaml | ||
|
||
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
||
|
@@ -123,19 +137,11 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in | |
# rollback kustomize edit | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||
|
||
|
||
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. | ||
$(KUSTOMIZE) build config/default | kubectl delete -f - | ||
|
||
AUTHORINO_VERSION ?= latest | ||
ifeq (latest,$(AUTHORINO_VERSION)) | ||
AUTHORINO_BRANCH = main | ||
else | ||
AUTHORINO_BRANCH = v$(AUTHORINO_VERSION) | ||
endif | ||
AUTHORINO_MANIFESTS ?= https://raw.githubusercontent.com/Kuadrant/authorino/$(AUTHORINO_BRANCH)/install/manifests.yaml | ||
install-authorino: ## install RBAC and CRD for authorino | ||
kubectl apply -f $(AUTHORINO_MANIFESTS) | ||
$(KUSTOMIZE) build config/authorino | kubectl apply -f - | ||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
|
@@ -160,13 +166,12 @@ rm -rf $$TMP_DIR ;\ | |
endef | ||
|
||
DEPLOYMENT_DIR = $(PROJECT_DIR)/config/deploy | ||
DEPLOYMENT_FILE = $(DEPLOYMENT_DIR)/$(shell basename $(AUTHORINO_MANIFESTS)) | ||
DEPLOYMENT_FILE = $(DEPLOYMENT_DIR)/manifests.yaml | ||
.PHONY: deploy-manifest | ||
deploy-manifest: | ||
mkdir -p $(DEPLOYMENT_DIR) | ||
curl -sSf $(AUTHORINO_MANIFESTS) > $(DEPLOYMENT_FILE) && sed -i '$${/^$$/d;}' $(DEPLOYMENT_FILE) && echo '---' >> $(DEPLOYMENT_FILE) | ||
cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=$(OPERATOR_IMAGE) ;\ | ||
cd $(PROJECT_DIR) && $(KUSTOMIZE) build config/default >> $(DEPLOYMENT_FILE) | ||
cd $(PROJECT_DIR) && $(KUSTOMIZE) build config/deploy > $(DEPLOYMENT_FILE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot safer this way. TBH, I didn't know kustomize allowed to point to remote resources. Apparently since March 2020. |
||
# clean up | ||
cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||
|
||
|
@@ -175,29 +180,18 @@ OPERATOR_SDK_VERSION = v1.15.0 | |
operator-sdk: ## Download operator-sdk locally if necessary. | ||
./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) | ||
|
||
ifeq (latest,$(OPERATOR_VERSION)) | ||
OPERATOR_BUNDLE_VERSION = 0.0.0 | ||
else | ||
OPERATOR_BUNDLE_VERSION = $(OPERATOR_VERSION) | ||
endif | ||
TMP_BUNDLE_DIR = $(PROJECT_DIR)/tmp/bundles | ||
.PHONY: bundle | ||
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. | ||
rm -rf $(TMP_BUNDLE_DIR) | ||
$(OPERATOR_SDK) generate kustomize manifests -q | ||
mkdir -p $(TMP_BUNDLE_DIR) | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=$(OPERATOR_IMAGE) | ||
$(KUSTOMIZE) build $(PROJECT_DIR)/config/manifests > $(TMP_BUNDLE_DIR)/authorino-operator-manifests.yaml | ||
curl $(AUTHORINO_MANIFESTS) > $(TMP_BUNDLE_DIR)/authorino-manifests.yaml | ||
$(OPERATOR_SDK) generate bundle -q --overwrite --version $(OPERATOR_BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS) --package authorino-operator --input-dir $(TMP_BUNDLE_DIR) | ||
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) --package authorino-operator | ||
$(OPERATOR_SDK) bundle validate ./bundle | ||
# Roll back edit | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||
|
||
.PHONY: bundle-build | ||
bundle-build: bundle ## Build the bundle image. | ||
cd $(TMP_BUNDLE_DIR) && docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . | ||
rm -rf $(TMP_BUNDLE_DIR) | ||
bundle-build: ## Build the bundle image. | ||
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . | ||
|
||
.PHONY: bundle-push | ||
bundle-push: ## Push the bundle image. | ||
|
@@ -225,7 +219,7 @@ endif | |
BUNDLE_IMGS ?= $(BUNDLE_IMG) | ||
|
||
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). | ||
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(OPERATOR_TAG) | ||
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(IMAGE_TAG) | ||
|
||
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. | ||
ifneq ($(origin CATALOG_BASE_IMG), undefined) | ||
|
@@ -239,6 +233,10 @@ endif | |
catalog-build: opm ## Build a catalog image. | ||
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) | ||
|
||
.PHONY: catalog-generate | ||
catalog-generate: opm ## Generate a catalog/index Dockerfile. | ||
$(OPM) index add --generate --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) | ||
|
||
# Push the catalog image. | ||
.PHONY: catalog-push | ||
catalog-push: ## Push a catalog image. | ||
|
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,2 @@ | ||
resources: | ||
- github.com/Kuadrant/authorino/install?ref=${AUTHORINO_GITREF} |
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,2 @@ | ||
resources: | ||
- github.com/Kuadrant/authorino/install?ref=main |
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,3 @@ | ||
resources: | ||
- ../authorino | ||
- ../default |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will require some coordination to update existing references to quay.io/3scale/authorino-operator.
https://github.com/Kuadrant/authorino-operator/blob/main/.github/workflows/build-latest.yaml should also go away.