Skip to content

Instantly share code, notes, and snippets.

@vidhya03
Created June 25, 2023 02:28
Show Gist options
  • Save vidhya03/1111d883b31cc7dfb7821b10ca8a58ae to your computer and use it in GitHub Desktop.
Save vidhya03/1111d883b31cc7dfb7821b10ca8a58ae to your computer and use it in GitHub Desktop.
Automating the version change by checking out the repository and changing the version and commit ,push and create new PR
dir_root_path="/path-to/codeline-version-change/"
files=(
"microservice1;[email protected]:AIM/microservice1"
"microservice2;[email protected]:AIM/microservice2"
"microservice3;[email protected]:AIM/microservice3"
)
itrac_codeline="JIRA-2345"
old_version="3.2.2"
new_version="3.3.0"
label="10.17.2.0"
newbranch="bugfix/$itrac_codeline"
for i in "${files[@]}"
do
IN=$i
set -- "$IN"
IFS=";"; declare -a Array=($*)
dir_name="${Array[0]}"
clone_url="${Array[1]}"
echo "$dir_root_path$dir_name"
git clone $clone_url --config core.sshCommand="ssh -i /path-to/keys/rsanopass" "$dir_root_path""$dir_name"
cd "$dir_root_path$dir_name"
git checkout develop
git reset --hard origin/develop
git pull
git config user.name "Vidhyadharan Deivamani"
git config user.email "[email protected]"
git checkout -b $newbranch
sed -i "s:\bversion=$old_version\b:version=$new_version:g" $dir_root_path$dir_name/gradle.properties
git add $dir_root_path$dir_name/gradle.properties
git commit -m "ci($itrac_codeline): Updated version"
git push --set-upstream origin $newbranch
gh pr create -t "[$dir_name]ci($itrac_codeline): Updated version" -b "[$dir_name] ci($itrac_codeline): Updated version" --base develop --head $newbranch -a <replace this with reviewer username> -l $label
echo "$newbranch have been created $i and PR also created"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment