29 lines
709 B
Bash
Executable File
29 lines
709 B
Bash
Executable File
!/bin/bash
|
|
|
|
#get image name
|
|
remote_url=$(git remote get-url origin)
|
|
image=$(echo $remote_url | sed 's|https://||g; s|.git||g')
|
|
|
|
#get branch name
|
|
branch_name=$(git rev-parse --abbrev-ref HEAD)
|
|
clean_branch_name=${branch_name##*/}
|
|
|
|
#get timestamp for the tag
|
|
timestamp=$(date +%Y%m%d%H%M%S)
|
|
|
|
app_version=$clean_branch_name-$timestamp
|
|
tag=$image:$timestamp-$clean_branch_name
|
|
latest=$image:latest-$clean_branch_name
|
|
|
|
#build image
|
|
docker build --build-arg APP_VERSION=$app_version -t $tag .
|
|
docker tag $tag $latest
|
|
|
|
#push to dockerhub
|
|
docker login git.rssa.top -u stim -p 2ad87eeef27b3ac1acd58271fdc1b4af934d180c
|
|
docker push $tag
|
|
docker push $latest
|
|
|
|
#remove dangling images
|
|
docker system prune -f
|