Skip to content

Commit

Permalink
US-393502 : pega-helm-chart version in repo should match build versio…
Browse files Browse the repository at this point in the history
…ns (#699)

Chart version sync
  • Loading branch information
chandra-prakash-reddy authored Feb 6, 2024
1 parent 36e377b commit 4b46c50
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,13 @@ jobs:
cd $GITHUB_WORKSPACE
chmod 777 update_gh_pages.sh
./update_gh_pages.sh
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_SECRET }}

- name: sync chart version
run: |
cd $GITHUB_WORKSPACE
chmod 777 sync_chart_version.sh
./sync_chart_version.sh
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_SECRET }}
2 changes: 1 addition & 1 deletion charts/addons/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: addons
version: 1.2.0
version: "1.2.0"
2 changes: 1 addition & 1 deletion charts/backingservices/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ description: Helm Chart to provision the latest Search and Reporting Service (SR
# The chart version: Pega provides this as a useful way to track changes you make to this chart.
# As a best practice, you should increment the version number each time you make changes to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.2.0
version: "1.2.0"
46 changes: 46 additions & 0 deletions sync_chart_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -e
tagVersion=""
if [ ${GITHUB_REF_TYPE} == "tag" ]
then
tagVersion=${GITHUB_REF_NAME}
fi
export CHART_VERSION=$(expr ${tagVersion:1})

echo "${GITHUB_REF}"
echo "${GITHUB_REPOSITORY}"
echo "${GITHUB_ACTOR}"

repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_name="origin"
target_branch="master"
tmp_build_dir="/tmp/build_dir"

cd "$GITHUB_WORKSPACE"

git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "${GITHUB_ACTOR}@bots.github.com"

echo "Creating a temporary directory to build"
mkdir -p "$tmp_build_dir"

echo "clone a single branch master"
git clone --quiet --branch="$target_branch" --depth=1 "$repo_uri" "$tmp_build_dir" > /dev/null

cd "$tmp_build_dir"

# Update version in charts/pega/Chart.yaml
awk -v new_version="${CHART_VERSION}" '/^version:/ {$2="\"" new_version "\""}1' charts/pega/Chart.yaml > temp && mv temp charts/pega/Chart.yaml
# Update version in charts/addons/Chart.yaml
awk -v new_version="${CHART_VERSION}" '/^version:/ {$2="\"" new_version "\""}1' charts/addons/Chart.yaml > temp && mv temp charts/addons/Chart.yaml
# Update version in charts/backingservices/Chart.yaml
awk -v new_version="${CHART_VERSION}" '/^version:/ {$2="\"" new_version "\""}1' charts/backingservices/Chart.yaml > temp && mv temp charts/backingservices/Chart.yaml

# Commit changes
git add charts/pega/Chart.yaml charts/addons/Chart.yaml charts/backingservices/Chart.yaml

echo "Updating chart versions to ${CHART_VERSION}"
git commit -m "Update chart versions to ${CHART_VERSION}"

echo "Pushing to master"
git push -q "$remote_name" "$target_branch" > /dev/null

0 comments on commit 4b46c50

Please sign in to comment.