diff --git a/.github/workflows/github-actions-build.yml b/.github/workflows/github-actions-build.yml index 19e5598c5..59206e93b 100644 --- a/.github/workflows/github-actions-build.yml +++ b/.github/workflows/github-actions-build.yml @@ -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 }} \ No newline at end of file diff --git a/charts/addons/Chart.yaml b/charts/addons/Chart.yaml index f72a0b21a..c4b74dec7 100644 --- a/charts/addons/Chart.yaml +++ b/charts/addons/Chart.yaml @@ -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" diff --git a/charts/backingservices/Chart.yaml b/charts/backingservices/Chart.yaml index 7d812fe68..9f3f9c4db 100644 --- a/charts/backingservices/Chart.yaml +++ b/charts/backingservices/Chart.yaml @@ -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" diff --git a/sync_chart_version.sh b/sync_chart_version.sh new file mode 100644 index 000000000..3da109dd9 --- /dev/null +++ b/sync_chart_version.sh @@ -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 \ No newline at end of file