Tweaked backend build
This commit is contained in:
parent
ce98565ae3
commit
1717e599db
@ -8,20 +8,14 @@ jabba use 21.0.2
|
|||||||
# Set variables
|
# Set variables
|
||||||
IMAGE_NAME="nise-backend"
|
IMAGE_NAME="nise-backend"
|
||||||
IMAGE_REGISTRY="git.gengo.tech/gengotech"
|
IMAGE_REGISTRY="git.gengo.tech/gengotech"
|
||||||
IMAGE_VERSION=$(grep -m2 "<version>" pom.xml | tail -n1 | sed 's/[[:space:]]*<version>//;s/<\/version>//')
|
IMAGE_VERSION="latest"
|
||||||
|
|
||||||
# Check if there are uncommitted changes
|
# Check if there are uncommitted changes
|
||||||
if [[ -n $(git status --porcelain) ]]; then
|
if [[ -n $(git status --porcelain) ]]; then
|
||||||
git add .
|
echo "Error: There are uncommitted changes. Please commit them before building."
|
||||||
git commit -m "Build and push v$IMAGE_VERSION"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# List variables and prompt to continue
|
|
||||||
echo "Variables:"
|
|
||||||
echo "IMAGE_NAME=$IMAGE_NAME"
|
|
||||||
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY"
|
|
||||||
echo "IMAGE_VERSION=$IMAGE_VERSION"
|
|
||||||
|
|
||||||
rm -rf target/
|
rm -rf target/
|
||||||
|
|
||||||
# Clean and build Maven project
|
# Clean and build Maven project
|
||||||
@ -45,25 +39,5 @@ if [ "$?" != "0" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker tag $IMAGE_NAME:$IMAGE_VERSION $IMAGE_REGISTRY/$IMAGE_NAME:latest
|
|
||||||
docker push $IMAGE_REGISTRY/$IMAGE_NAME:latest
|
|
||||||
if [ "$?" != "0" ]; then
|
|
||||||
echo "Error: Failed to push $IMAGE_REGISTRY/$IMAGE_NAME:latest"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Successfully built and pushed $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION and $IMAGE_REGISTRY/$IMAGE_NAME:latest"
|
|
||||||
echo "Docker image pushed successfully to $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION"
|
echo "Docker image pushed successfully to $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION"
|
||||||
|
|
||||||
# Add and commit changes to git
|
|
||||||
git add .
|
|
||||||
git commit -m "Build and push v$IMAGE_VERSION"
|
|
||||||
|
|
||||||
# Create annotated tag with commit message
|
|
||||||
git tag -a release-$IMAGE_VERSION -m "Release v$IMAGE_VERSION"
|
|
||||||
|
|
||||||
# Push changes and tags to remote repository
|
|
||||||
git push && git push --tags
|
|
||||||
|
|
||||||
echo "Successfully pushed changes and tags to remote repository"
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user