Skip to content

Commit

Permalink
Merge pull request #109 from sivanaikk/ci/github-actions
Browse files Browse the repository at this point in the history
Feat: added build pipeline, version upgrade
  • Loading branch information
karun-singh authored Apr 2, 2024
2 parents 7ffc8b2 + 5e4bd6a commit 8fe8f93
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This github workflow will automatically update docker image tags of gis-depl in the datakaveri/iudx-deployment repository files, whenever docker image is pushed to ghcr.io/datakaveri/gis-depl .Based on tag it will update the master/latest branch (if its 5.0.0-alpha-) or 4.5.0 stable branch (if its 4.5.0-)
# This github workflow will automatically update docker image tags of gis-depl in the datakaveri/iudx-deployment repository files, whenever docker image is pushed to ghcr.io/datakaveri/gis-depl .Based on tag it will update the master/latest branch (if its 5.5.1-alpha-) or 5.5.0 stable branch (if its 5.5.0-)
name: Update GIS docker image tags

# This trigger will run the workflow whenever a new package is published to the registry
Expand Down Expand Up @@ -27,26 +27,26 @@ jobs:
env:
GH_TOKEN: ${{ secrets.JENKINS_UPDATE}}
run: |
# Get the latest version of 4.5.0 and 5.0.0-alpha tags from the container registry using GitHub API
export newtag4_5_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 4.5.0 | sed -e 's/^"//' -e 's/"$//'))`
export newtag5_0_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.0.0-alpha | sed -e 's/^"//' -e 's/"$//'))`
# Get the latest version of 5.5.0 and 5.5.1-alpha tags from the container registry using GitHub API
export newtag5_5_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.0 | grep -v alpha | sed -e 's/^"//' -e 's/"$//'))`
export newtag5_5_1=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.1-alpha | sed -e 's/^"//' -e 's/"$//'))`
# Get the old tags from the YAML files
export oldtag5_0_0=`yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2`
git checkout 4.5.0
export oldtag4_5_0=$(yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2)
export oldtag5_5_1=`yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2`
git checkout 5.5.0
export oldtag5_5_0=$(yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2)
# Set Git user
git config --global user.name 'jenkins-datakaveri'
git config --global user.email "[email protected]"
# Update the YAML files and create a new branch for each tag update
if [ "$newtag4_5_0" != "$oldtag4_5_0" ]
if [ "$newtag5_5_0" != "$oldtag5_5_0" ]
then
git checkout -b gis-4.5.0-automatic-updates/$newtag4_5_0
git checkout -b gis-5.5.0-automatic-updates/$newtag5_5_0
# Uses sed to find and replace $oldtag4_5_0 with $newtag4_5_0 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file
sed -i s/$oldtag4_5_0/$newtag4_5_0/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml
# Uses sed to find and replace $oldtag5_5_0 with $newtag5_5_0 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file
sed -i s/$oldtag5_5_0/$newtag5_5_0/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml
# Exports the current version of the application from K8s-deployment/Charts/gis-interface/Chart.yaml file
export oldappversion=`yq -r .version K8s-deployment/Charts/gis-interface/Chart.yaml`
Expand All @@ -56,33 +56,33 @@ jobs:
# Uses sed to find and replace $oldappversion with $newappversion in K8s-deployment/Charts/gis-interface/Chart.yaml and K8s-deployment/Charts/gis-interface/values.yaml files
sed -i s/$oldappversion/$newappversion/g K8s-deployment/Charts/gis-interface/Chart.yaml
sed -i s/$oldtag4_5_0/$newtag4_5_0/g K8s-deployment/Charts/gis-interface/values.yaml
sed -i s/$oldtag5_5_0/$newtag5_5_0/g K8s-deployment/Charts/gis-interface/values.yaml
git add Docker-Swarm-deployment/single-node/gis/gis-stack.yaml K8s-deployment/Charts/gis-interface/values.yaml K8s-deployment/Charts/gis-interface/Chart.yaml
git commit --allow-empty -m "updated GIS docker image tag to $newtag4_5_0"
git push --set-upstream origin gis-4.5.0-automatic-updates/$newtag4_5_0
git commit --allow-empty -m "updated GIS docker image tag to $newtag5_5_0"
git push --set-upstream origin gis-5.5.0-automatic-updates/$newtag5_5_0
# Creates a new pull request on the datakaveri/iudx-deployment repository with the base branch 4.5.0
gh pr create -R datakaveri/iudx-deployment --base 4.5.0 --fill
# Creates a new pull request on the datakaveri/iudx-deployment repository with the base branch 5.5.0
gh pr create -R datakaveri/iudx-deployment --base 5.5.0 --fill
fi
if [ "$newtag5_0_0" != "$oldtag5_0_0" ]
if [ "$newtag5_5_1" != "$oldtag5_5_1" ]
then
git checkout master
git checkout -b gis-automatic-updates/$newtag5_0_0
git checkout -b gis-automatic-updates/$newtag5_5_1
# Uses sed to find and replace $oldtag5_0_0 with $newtag5_0_0 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file
sed -i s/$oldtag5_0_0/$newtag5_0_0/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml
# Uses sed to find and replace $oldtag5_5_1 with $newtag5_5_1 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file
sed -i s/$oldtag5_5_1/$newtag5_5_1/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml
# Exports the current version of the application from K8s-deployment/Charts/gis-interface/Chart.yaml file
export oldappversion=`yq -r .version K8s-deployment/Charts/gis-interface/Chart.yaml`
# Uses sed to find and replace $oldappversion with $newappversion in K8s-deployment/Charts/gis-interface/Chart.yaml and K8s-deployment/Charts/gis-interface/values.yaml files
export newappversion=`yq -r .version K8s-deployment/Charts/gis-interface/Chart.yaml | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}' `
sed -i s/$oldappversion/$newappversion/g K8s-deployment/Charts/gis-interface/Chart.yaml
sed -i s/$oldtag5_0_0/$newtag5_0_0/g K8s-deployment/Charts/gis-interface/values.yaml
sed -i s/$oldtag5_5_1/$newtag5_5_1/g K8s-deployment/Charts/gis-interface/values.yaml
git add Docker-Swarm-deployment/single-node/gis/gis-stack.yaml K8s-deployment/Charts/gis-interface/values.yaml K8s-deployment/Charts/gis-interface/Chart.yaml
git commit --allow-empty -m "updated GIS docker image tag to $newtag5_0_0"
git push --set-upstream origin gis-automatic-updates/$newtag5_0_0
git commit --allow-empty -m "updated GIS docker image tag to $newtag5_5_1"
git push --set-upstream origin gis-automatic-updates/$newtag5_5_1
# Creates a new pull request on the datakaveri/iudx-deployment repository with the base branch master
gh pr create -R datakaveri/iudx-deployment --base master --fill
fi
Expand Down

0 comments on commit 8fe8f93

Please sign in to comment.