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

Add image build GH action #8

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

mikenairn
Copy link
Member

@mikenairn mikenairn commented Feb 1, 2022

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

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)
Copy link
Member Author

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.

@mikenairn mikenairn requested a review from a team February 1, 2022 15:15
Copy link
Contributor

@eguzki eguzki left a 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
Copy link
Contributor

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?

Copy link
Member Author

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 }}
Copy link
Contributor

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?

Copy link
Member Author

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

@mikenairn mikenairn merged commit 4195c85 into Kuadrant:main Feb 2, 2022
@mikenairn mikenairn deleted the add_image_build_actions branch February 2, 2022 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants