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

added helm charts steps into push pipeline #3

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Update Chart Version
env:
VERSION: ${{ steps.generate_tag.outputs.new_tag }}
run: make bump-chart

- name: Update Chart CRDs
run: make generate-crds

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.8.2

- name: Login to Container Registry
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -79,6 +92,39 @@ jobs:
IMAGE_DIGEST: ${{ steps.build_and_push.outputs.digest }}
VERSION: ${{ steps.generate_tag.outputs.new_tag }}


# Publish helm chart
- name: Publish Helm chart
run: |
helm dependency build ./charts/grafana-oncall
helm package ./charts/grafana-oncall --destination ./packaged-chart
helm push ./packaged-chart/*.tgz oci://ghcr.io/stakater/charts
rm -rf ./packaged-chart

# Commit back changes
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "stakater-github-root"
git status
git add .
git reset bundle/
git commit -m "[skip-ci] Update artifacts" -a

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
branch: main

- name: Push Latest Tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }}
DEFAULT_BUMP: patch
RELEASE_BRANCHES: main
WITH_V: false

outputs:
image_repository: ${{ env.IMAGE_REPOSITORY }}
version: ${{ steps.generate_tag.outputs.new_tag }}
Expand Down
40 changes: 38 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ IMAGE_TAG_BASE ?= ghcr.io/stakater/grafana-cloud-ansible-operator

# 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:v$(VERSION)
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)$(PR_TAG)
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)$(PR_TAG)

# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION)$(PR_TAG) $(BUNDLE_METADATA_OPTS)

# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
Expand All @@ -66,6 +67,7 @@ OPERATOR_SDK_VERSION ?= v1.31.0

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):v$(VERSION)
CUSTOM_CATALOG_IMG ?= $(IMAGE_TAG_BASE)@$(IMAGE_DIGEST)

.PHONY: all
all: docker-build
Expand Down Expand Up @@ -196,6 +198,14 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: custom-bundle
custom-bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files
rm -rf bundle
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(CUSTOM_CATALOG_IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
Expand Down Expand Up @@ -243,3 +253,29 @@ catalog-build: opm ## Build a catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)


##@ Helm

.PHONY: helm-lint
helm-lint: ## Lint Helm charts, if they exist
if [ -d charts ]; then helm lint charts/grafana-oncall; fi

.PHONY: bump-chart-operator
bump-chart-operator:
$(SED) -i "s/^VERSION ?=.*/VERSION ?= $(VERSION)/" Makefile
$(SED) -i "s/newTag:.*/newTag: v$(VERSION)/" config/manager/kustomization.yaml
$(SED) -i "s/^version:.*/version: $(VERSION)/" charts/grafana-oncall/Chart.yaml
$(SED) -i "s/^appVersion:.*/appVersion: $(VERSION)/" charts/grafana-oncall/Chart.yaml
$(SED) -i "s/tag:.*/tag: v$(VERSION)/" charts/grafana-oncall/values.yaml

.PHONY: bump-chart
bump-chart: bump-chart-operator ## Bump version accross the project

crds=`ls charts/tenant-operator/crds/`
.PHONY: generate-crds
generate-crds: generate manifests kustomize-and-generate-crds list ## Update auto-generated files and charts/tenant-operator/crds

kustomize-and-generate-crds: kustomize
mkdir -p charts/tenant-operator/crds
./bin/kustomize build config/crd -o charts/tenant-operator/crds/