diff --git a/TTT/Dockerfile b/TTT/Dockerfile index a120c8a..acb68a0 100644 --- a/TTT/Dockerfile +++ b/TTT/Dockerfile @@ -1,4 +1,6 @@ -FROM jusito/docker-ttt:gmod_debian +ARG SUFFIX="" + +FROM jusito/docker-ttt:gmod_debian${SUFFIX} ENV SERVER_GAMEMODE="terrortown" diff --git a/gmod/Dockerfile b/gmod/Dockerfile index 8b53e27..0ebf797 100644 --- a/gmod/Dockerfile +++ b/gmod/Dockerfile @@ -1,4 +1,6 @@ -FROM jusito/docker-ttt:lgsm_debian +ARG SUFFIX="" + +FROM jusito/docker-ttt:lgsm_debian${SUFFIX} # Const \\ Overwrite Env \\ Configs optional ENV CSS_PATH="/home/steam/addons/css" \ diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index 0362140..c30bb9b 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -19,11 +19,12 @@ function configReplace() { echo "[initConfig.sh]Request for replacing $source to $target, source is found $count times" if [ "$count" == "1" ]; then - sed -Ei "s/${source}.*/${source} ${target}/g" "${CFG_PATH}" + sed -Ei "/${source}.*/d" "${CFG_PATH}" + echo "$source $target" >> "${CFG_PATH}" elif [ "$count" == "0" ]; then echo "" >> "${CFG_PATH}" - echo "$target" >> "${CFG_PATH}" + echo "$source $target" >> "${CFG_PATH}" else echo "[initConfig.sh]can't set $1 because there are multiple in" diff --git a/lgsm/hooks/pre_push b/lgsm/hooks/pre_push index 3aa7369..c274c60 100644 --- a/lgsm/hooks/pre_push +++ b/lgsm/hooks/pre_push @@ -1,17 +1,19 @@ #!/bin/sh -#set -o errexit +set -o errexit #set -o pipefail -#set -o nounset +set -o nounset -#docker build -t "$DOCKER_REPO:lgsm_debian" "lgsm/" +imageSuffix="" +if [ "$SOURCE_BRANCH" != "master" ]; then + imageSuffix="-$(echo "$SOURCE_BRANCH" | sed 's/\//-/g')" +fi + +#docker build -t "$DOCKER_REPO:lgsm_debian${imageSuffix}" "lgsm/" cd .. -docker build -t "$DOCKER_REPO:gmod_debian" "gmod/" -docker build -t "$DOCKER_REPO:gmod_ttt_debian" "TTT/" -docker tag "$DOCKER_REPO:gmod_ttt_debian" "$DOCKER_REPO:latest" - -docker push "$DOCKER_REPO:gmod_debian" -docker push "$DOCKER_REPO:gmod_ttt_debian" -docker push "$DOCKER_REPO:latest" +bash test/testBuild.sh "$imageSuffix" true +docker push "$DOCKER_REPO:gmod_debian${imageSuffix}" +docker push "$DOCKER_REPO:gmod_ttt_debian${imageSuffix}" +docker push "$DOCKER_REPO:latest${imageSuffix}" diff --git a/test/testBuild.sh b/test/testBuild.sh index 05d13d1..e813ebd 100644 --- a/test/testBuild.sh +++ b/test/testBuild.sh @@ -1,5 +1,8 @@ #!/bin/bash +readonly SUFFIX="$1" +readonly SKIP_LGSM="$2" + if [ "${DEBUGGING}" = "true" ]; then set -o xtrace else @@ -12,11 +15,16 @@ set -o pipefail echo "[testBuild][INFO]build" -docker rmi "jusito/docker-ttt:lgsm_debian" || true -docker build --no-cache -t "jusito/docker-ttt:lgsm_debian" "lgsm/" +if [ "$SKIP_LGSM" = true ]; then + docker rmi "jusito/docker-ttt:lgsm_debian${SUFFIX}" || true + docker build --no-cache -t "jusito/docker-ttt:lgsm_debian${SUFFIX}" "lgsm/" +fi -docker rmi "jusito/docker-ttt:gmod_debian" || true -docker build --no-cache -t "jusito/docker-ttt:gmod_debian" "gmod/" +docker rmi "jusito/docker-ttt:gmod_debian${SUFFIX}" || true +docker build --no-cache -t "jusito/docker-ttt:gmod_debian${SUFFIX}" "gmod/" -docker rmi "jusito/docker-ttt:gmod_ttt_debian" || true -docker build --no-cache -t "jusito/docker-ttt:gmod_ttt_debian" "TTT/" \ No newline at end of file +docker rmi "jusito/docker-ttt:gmod_ttt_debian${SUFFIX}" || true +docker build --no-cache -t "jusito/docker-ttt:gmod_ttt_debian${SUFFIX}" "TTT/" + +docker rmi "$DOCKER_REPO:latest${SUFFIX}" || true +docker tag "$DOCKER_REPO:gmod_ttt_debian${SUFFIX}" "$DOCKER_REPO:latest${SUFFIX}" \ No newline at end of file