-
Notifications
You must be signed in to change notification settings - Fork 33
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 image build GH action #8
Conversation
Adds a GitHub action trigger on branch/tag creation that builds and pushes the operator, bundle and index images. Notes: OLM Bundle version is always set to 0.0.0 for builds of 'main' branch. Images built from the 'main' branch are also tagged as 'latest' and all images reference the 'latest' builds i.e. index(latest) -> bundle(latest) -> operator(latest).
@@ -282,6 +282,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) |
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.
This generates an index.Dockerfile rather than triggering a docker build so we can instead build it using the same process as the others.
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.
good work! 🎖️
- 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 |
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.
should the workflow fail if git diff is not empty?
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.
Not for main, but for anything else, maybe/probably. We are modifying the VERSION to always be "0.0.0" and forcing the latest tag when building main, so the git diff should show changes. I put this here so i could check what it was doing, but you are right, we might want to consider failing it if there are unexpected changes for release tags or branches.
dockerfiles: | | ||
./bundle.Dockerfile | ||
- name: Push Image | ||
if: ${{ !env.ACT }} |
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.
what is the purpose of this condition? what is env.ACT
?
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.
I've been using act to test these actions locally. It adds this env var by default, and it's just to stop it doing any push locally when testing.
tbh, act didn't really work well for this action because of the buildah/podman dependencies (wasted a lot of time trying to get it to work), but it works fine for testing the test action, you can use the make command to try it make act-pull-request-jobs
Adds a GitHub action triggered on branch/tag creation that builds and pushes the operator, bundle and index images.
OLM Bundle version is always set to 0.0.0 for builds of 'main' branch.
Images built from the 'main' branch are also tagged as 'latest' and all images reference the 'latest' builds i.e. index(latest) ->
bundle(latest) -> operator(latest).
Tested here https://github.com/mikenairn/kuadrant-operator/actions
Example main branch build: https://github.com/mikenairn/kuadrant-operator/actions/runs/1778709855
Example tag build https://github.com/mikenairn/kuadrant-operator/actions/runs/1778795829