diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2021-04-17 10:38:45 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2021-04-17 10:38:45 +0200 |
| commit | 92e6e4404e92fb604effc98110111db1b42482b6 (patch) | |
| tree | ce59fc69bc2c771d8728d1f15d38e2ab8a167107 /build_docker_image.sh | |
| parent | 0cbaa868f894e01fe97e091c49b6c140b5c66561 (diff) | |
| download | srht-git-feed-92e6e4404e92fb604effc98110111db1b42482b6.tar.xz srht-git-feed-92e6e4404e92fb604effc98110111db1b42482b6.zip | |
Add version.txt endpoint
Diffstat (limited to 'build_docker_image.sh')
| -rwxr-xr-x | build_docker_image.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/build_docker_image.sh b/build_docker_image.sh new file mode 100755 index 0000000..504dd4d --- /dev/null +++ b/build_docker_image.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +do_push() { + IMAGE_NAME="srht-git-feed" + HUB_NAME="ivarlovlie/srht-git-feed" + COMMIT_HASH=$(git rev-parse --short HEAD) + + echo $COMMIT_HASH >version.txt + docker build -t $IMAGE_NAME . + docker tag $IMAGE_NAME $HUB_NAME:$COMMIT_HASH + docker tag $IMAGE_NAME $HUB_NAME:latest + + echo "" + echo "CTRL+C to cancel, anything to push to docker hub" + read -n 1 + docker push $HUB_NAME:$COMMIT_HASH + docker push $HUB_NAME:latest +} + +if [ -z "$(git status --untracked-files=no --porcelain)" ]; then + do_push +else + echo "unclean git tree! CTRL+C to cancel, anything to commit and push to default branch" + read -n 1 + read -p "Enter commit message: " COMMIT_MESSAGE + git add . + git commit -m "$COMMIT_MESSAGE" + git push + do_push +fi |
