Last active
February 24, 2023 10:57
-
-
Save Thakurvaibhav/a59b0ba6387142d76359039a248adf39 to your computer and use it in GitHub Desktop.
Updating the nginx conf to depict current app version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Author: Vaibhav Thakur | |
#Checking whether commit was in master of not. | |
if_master=`echo $payload | jq '.ref' | grep master` | |
if [ $? -eq 1 ]; then | |
echo "Pipeline should not be triggered" | |
exit 2 | |
fi | |
#Getting tag from pom.xml | |
TAG=`grep SNAPSHOT pom.xml | sed 's|[<,>,/,version ]||g'` | |
echo $TAG | |
#Getting action from commit message | |
ACTION=$(echo $payload | jq -r '.commits[0].message' | cut -d',' -f2) | |
#Updating index.html | |
sed -i -- "s/VER/${TAG}/g" app/index.html | |
#Pushing to dockerhub | |
docker build -t vaibhavthakur/nginx-demo:$TAG . | |
docker push vaibhavthakur/nginx-demo:$TAG | |
echo TAG=${TAG} > trigger.properties | |
echo ACTION=${ACTION} >> trigger.properties |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment