diff --git a/Makefile b/Makefile index 1e11391e8..cddcfb9cc 100644 --- a/Makefile +++ b/Makefile @@ -158,8 +158,10 @@ else OPERATOR_SDK=$(shell which operator-sdk) endif -check: lint-all ## Check all files lint error +check: lint-all get-cluster-credentials ## Check all files lint error ./common/scripts/lint-csv.sh + echo "Checking GHE pull" + @common/scripts/ghe_config.sh code-dev: ## Run the default dev commands which are the go tidy, fmt, vet then execute the $ make code-gen @echo Running the common required commands for developments purposes diff --git a/common/scripts/ghe_config.sh b/common/scripts/ghe_config.sh new file mode 100755 index 000000000..fe4ff064c --- /dev/null +++ b/common/scripts/ghe_config.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Copyright 2025 IBM Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +KUBECTL=$(which kubectl) +GIT_USERNAME=$(${KUBECTL} -n default get secret helm-repo-cred -o jsonpath='{.data.username}' | base64 --decode) +GIT_TOKEN=$(${KUBECTL} -n default get secret helm-repo-cred -o jsonpath='{.data.password}' | base64 --decode) + +URL_ENCODED_USERNAME=$(echo $GIT_USERNAME | jq -Rr @uri) + +retries=5 +sleep_timer=5 + +while true; do + + if [ $retries -eq 0 ]; then + break + fi + + rm -rf helm-charts-reduction + + git clone "https://$URL_ENCODED_USERNAME:$GIT_TOKEN@github.ibm.com/IBMPrivateCloud/helm-charts-reduction.git" + + git config --global user.email "operator@operator.com" + git config --global user.name "ibm-common-service-operator" + + cd helm-charts-reduction + git checkout staging + + cp -r ../helm-cluster-scoped/* source-charts/ibm-common-service-operator-cluster-scoped + cp -r ../helm/* source-charts/ibm-common-service-operator + + is_changes=$(git status --short) + if [ -z "${is_changes}" ]; then + echo "No changes to add/commit, skipping" + exit 0 + fi + git add . + git commit -s -m "updated helm files for ibm-common-service-operator" + git push + if [ $? -eq 0 ]; then + break + fi + retries=$(( retries - 1 )) +done