File tree Expand file tree Collapse file tree 4 files changed +131
-4
lines changed
Expand file tree Collapse file tree 4 files changed +131
-4
lines changed Original file line number Diff line number Diff line change 1+ name : Helm update
2+
3+
4+ on :
5+ workflow_call :
6+ workflow_dispatch :
7+
8+ jobs :
9+ verify-helm-changes :
10+ name : Verify if AKO helm charts needs updates
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout AKO repo
14+ uses : actions/checkout@v4
15+
16+ - name : Install devbox
17+ uses :
jetify-com/[email protected] 18+ with :
19+ enable-cache : ' true'
20+
21+ - name : Configure git
22+ run : |
23+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
24+ git config --global user.name "github-actions[bot]"
25+
26+ - name : Checkout Helm Repo
27+ run : |
28+ git clone https://github.com/mongodb/helm-charts.git ./helm-charts-cloned
29+ ls -lah
30+
31+ - name : Verify if CRDs were changed
32+ id : crd-check
33+ env :
34+ HELM_CRDS_PATH : " ./helm-charts-cloned/charts/atlas-operator-crds/templates"
35+ run : |
36+ devbox run -- "make helm-upd-crds"
37+
38+ - name : Verify if RBAC were changed
39+ id : rbac-check
40+ env :
41+ HELM_RBAC_FILE : " ./helm-charts-cloned/charts/atlas-operator/rbac.yaml"
42+ run : |
43+ devbox run -- "make helm-upd-rbac"
44+
45+ - name : Create PR for helm-charts repo
46+ env :
47+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48+ run : |
49+ cd ./helm-charts-cloned
50+
51+ if [[ -n $(git status --porcelain) ]]; then
52+ BRANCH_NAME=CRD-RBAC-changes-${{ github.run_id }}
53+ COMMIT_MSG="[autogenerated] update CRDs and RBAC ${{ github.run_id }}"
54+ echo "Changes detected. Creating PR"
55+ git checkout -b "${BRANCH_NAME}"
56+ git add .
57+ git commit -m "${COMMIT_MSG}"
58+ gh pr create -B main -H "${BRANCH_NAME}" --title "${COMMIT_MSG}" --body "${COMMIT_MSG}"
59+ fi
60+ echo "Nothing to commit"
Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ uninstall: manifests ## Uninstall CRDs from a cluster
225225.PHONY : deploy
226226deploy : generate manifests run-kind # # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
227227 @./scripts/deploy.sh
228-
228+
229229.PHONY : manifests
230230# Produce CRDs that work back to Kubernetes 1.16 (so 'apiVersion: apiextensions.k8s.io/v1')
231231manifests : CRD_OPTIONS ?= "crd:crdVersions=v1,ignoreUnexportedFields=true"
@@ -454,24 +454,31 @@ test-metrics:
454454.PHONY : test-tools # # Test all tools
455455test-tools : test-clean test-makejwt test-metrics
456456
457- .PHONY : sign
457+ .PHONY : sign
458458sign : # # Sign an AKO multi-architecture image
459459 @echo " Signing multi-architecture image $( IMG) ..."
460460 IMG=$(IMG ) SIGNATURE_REPO=$(SIGNATURE_REPO ) ./scripts/sign-multiarch.sh
461461
462462./ako.pem :
463463 curl $(AKO_SIGN_PUBKEY ) > $@
464464
465- .PHONY : verify
465+ .PHONY : verify
466466verify : ./ako.pem # # Verify an AKO multi-architecture image's signature
467467 @echo " Verifying multi-architecture image signature $( IMG) ..."
468468 IMG=$(IMG ) SIGNATURE_REPO=$(SIGNATURE_REPO ) \
469469 ./scripts/sign-multiarch.sh verify && echo " VERIFIED OK"
470470
471+ .PHONY : helm-upd-crds
472+ helm-upd-crds :
473+ HELM_CRDS_PATH=$(HELM_CRDS_PATH ) ./scripts/helm-upd-crds.sh
474+
475+ .PHONY : helm-upd-rbac
476+ helm-upd-rbac :
477+ HELM_RBAC_FILE=$(HELM_RBAC_FILE ) ./scripts/helm-upd-rbac.sh
478+
471479.PHONY : vulncheck
472480vulncheck : # # Run govulncheck to find vulnerabilities in code
473481 @./scripts/vulncheck.sh ./vuln-ignore
474-
475482
476483.PHONY : generate-sboms
477484generate-sboms : ./ako.pem # # Generate a released version SBOMs
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -eou pipefail
4+
5+ echo " Working dir: $( pwd) "
6+
7+ if [[ -z " ${HELM_CRDS_PATH} " ]]; then
8+ echo " HELM_CRDS_PATH is not set"
9+ exit 1
10+ fi
11+
12+ filesToCopy=()
13+ for filename in ./bundle/manifests/atlas.mongodb.com_* .yaml; do
14+ absName=" $( basename " $filename " ) "
15+ echo " Verifying file: ${filename} "
16+ if ! diff " $filename " " ${HELM_CRDS_PATH} " /" $absName " ; then
17+ filesToCopy+=(" $filename " )
18+ fi
19+ done
20+
21+ fLen=${# filesToCopy[@]}
22+ if [ " $fLen " -eq 0 ]; then
23+ echo " No CRD changes detected"
24+ exit 0
25+ fi
26+
27+ echo " The following CRD changes detected:"
28+ for (( i= 0 ; i < fLen; i++ )) ; do
29+ echo " ${filesToCopy[$i]} "
30+ done
31+
32+ for (( i= 0 ; i < fLen; i++ )) ; do
33+ echo " Copying ${filesToCopy[$i]} to ${HELM_CRDS_PATH} /"
34+ cp " ${filesToCopy[$i]} " " ${HELM_CRDS_PATH} " /
35+ done
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -eou pipefail
4+
5+ echo " Working dir: $( pwd) "
6+
7+ if [[ -z " ${HELM_RBAC_FILE} " ]]; then
8+ echo " HELM_RBAC_FILE is not set"
9+ exit 1
10+ fi
11+
12+ if [ ! -f " ${HELM_RBAC_FILE} " ]; then
13+ echo " File ${HELM_RBAC_FILE} does not exist. Skipping RBAC validation"
14+ exit 0
15+ fi
16+
17+ yq ' .spec.install.spec.clusterPermissions[0].rules' ./bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > rbac.yaml
18+
19+ echo " Comparing RBAC for CSV to RBAC in AKO helm chart"
20+ if ! diff rbac.yaml " $HELM_RBAC_FILE " ; then
21+ echo " Copying RBAC"
22+ cp rbac.yaml " $HELM_RBAC_FILE "
23+ else
24+ echo " No changes detected"
25+ fi
You can’t perform that action at this time.
0 commit comments