Skip to content

Instantly share code, notes, and snippets.

@mychaelgo
Created March 15, 2022 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mychaelgo/bdf2093dc191d6c55876f53e7f20e01e to your computer and use it in GitHub Desktop.
Save mychaelgo/bdf2093dc191d6c55876f53e7f20e01e to your computer and use it in GitHub Desktop.
# Turbolift recipe to update helm template versions
#
# prerequisites:
# 1. https://github.com/Skyscanner/turbolift#installation
# 2. https://github.com/mikefarah/yq#install
#
# assumptions:
# 1. you have all buddy pipeline definitions under `/.buddy` directory of each repo and they all have `.yaml` or `.yml` extension
# 2. you define the helm chart version in an action of type `HELM` which has a list of `execute_commands`, and the version is passed in like `--version $version`. In other words, there's an action that looks like:
# - action: Render k8s manifest from Helm chart
# type: HELM
# trigger_condition: ALWAYS
# helm_repository_region: ap-southeast-1
# helm_repository_integration:
# hash_id: 5e85761fc5f225000f97dd99
# setup_commands:
# - helm plugin install https://github.com/hypnoglow/helm-s3.git --version 0.10.0
# execute_commands:
# - bash .buddy/scripts/apply_helm.sh --version 1.13.2
# kubectl_version: v1.18.2
# helm_version: v3.2.1
BRANCH_NAME=DAS-10096-chore-update-helm
OLD_HELM_VERSION=1.13.3
TARGET_HELM_VERSION=~1.14.2
# Initialize
turbolift init -n $BRANCH_NAME
cd $BRANCH_NAME
# Add list of repositories, alternatively, use gh-search to generate the list
# if this is the first time you use this, it's recommended that you add one repo to this to test it out before rolling out to all repos
cat <<EOF > repos.txt
xendit/xendit-user-service
xendit/xendit-dashboard-ui
xendit/xendit-dashboard-gateway
xendit/instamoney-dashboard-gateway
xendit/user-activity-service
xendit/dashboard-notification-center
xendit/dashboard-gateway-platform
EOF
# Edit PR title and description
cat <<EOF > README.md
# chore: update helm chart version
Update helm chart version to $TARGET_HELM_VERSION
EOF
cat <<EOF > update.sh
#!/bin/sh
FILES=\$(ls .buddy/*.{yml,yaml})
for FILE in \$FILES; do
sed -i '' -e "s/--version $OLD_HELM_VERSION/--version $TARGET_HELM_VERSION/g" \$FILE;
done
EOF
turbolift clone --no-fork
turbolift foreach sh $PWD/update.sh
turbolift commit --message "chore: update helm version"
turbolift foreach git push -u origin $BRANCH_NAME --no-verify --force
turbolift create-prs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment