Skip to content

Commit

Permalink
Feat: added build pipeline, version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
sivanaikk committed Apr 1, 2024
1 parent 7ffc8b2 commit 214fe8a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 23 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
compile:
runs-on: ubuntu-latest
name: Running Java ${{ matrix.java }} compile
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Compile code
run: mvn clean compile
build:
runs-on: ubuntu-latest
name: build
needs: compile
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: mvn clean -B package --file pom.xml -Dmaven.test.skip=true
test:
runs-on: ubuntu-latest
name: run tests
needs: compile
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run unit tests
run: mvn clean test
coverage:
runs-on: ubuntu-latest
name: coverage
needs: compile
steps:
- name: coverage with maven
uses: actions/checkout@v2
with:
java-version: 11
- name: build and coverage
run: mvn clean -B verify --no-transfer-progress
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 | 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 214fe8a

Please sign in to comment.