diff --git a/lgsm/hooks/pre_push b/lgsm/hooks/pre_push index 051d72b..3cca663 100644 --- a/lgsm/hooks/pre_push +++ b/lgsm/hooks/pre_push @@ -10,8 +10,4 @@ fi cd .. -bash test/testBuild.sh "$imageSuffix" - -docker push "$DOCKER_REPO:gmod_debian${imageSuffix}" -docker push "$DOCKER_REPO:gmod_ttt_debian${imageSuffix}" -docker push "$DOCKER_REPO:latest${imageSuffix}" +bash test/testBuild.sh "$imageSuffix" --push diff --git a/test/testBuild.sh b/test/testBuild.sh index e56ef99..6f9ec70 100644 --- a/test/testBuild.sh +++ b/test/testBuild.sh @@ -1,7 +1,8 @@ #!/bin/bash readonly SUFFIX="$1" -readonly BUILD_LGSM="$(grep -qF '--skip-lgsm' <<< "$@" && echo false || echo true)" +readonly BUILD_LGSM="$(grep -qF -e '--skip-lgsm' <<< "$@" && echo false || echo true)" +readonly PUSH="$(grep -qF -e '--push' <<< "$@" && echo true || echo false)" readonly repository="${DOCKER_REPO:-jusito/docker-ttt}" if [ "${DEBUGGING}" = "true" ]; then @@ -14,18 +15,27 @@ set -o errexit set -o nounset set -o pipefail +function process() { + tag_prefix="$1" + subdir="$2" + + docker rmi "$repository:$tag_prefix${SUFFIX}" || true + docker build --no-cache -t "$repository:$tag_prefix${SUFFIX}" "$subdir" + if "$PUSH"; then + docker push "$repository:$tag_prefix${SUFFIX}" + fi +} + echo "[testBuild][INFO]build" if "$BUILD_LGSM"; then - docker rmi "$repository:lgsm_debian${SUFFIX}" || true - docker build --no-cache -t "$repository:lgsm_debian${SUFFIX}" "lgsm/" + process "lgsm_debian" "lgsm/" fi - -docker rmi "$repository:gmod_debian${SUFFIX}" || true -docker build --no-cache -t "$repository:gmod_debian${SUFFIX}" "gmod/" - -docker rmi "$repository:gmod_ttt_debian${SUFFIX}" || true -docker build --no-cache -t "$repository:gmod_ttt_debian${SUFFIX}" "TTT/" +process "gmod_debian" "gmod/" +process "gmod_ttt_debian" "TTT/" docker rmi "$repository:latest${SUFFIX}" || true docker tag "$repository:gmod_ttt_debian${SUFFIX}" "$repository:latest${SUFFIX}" +if "$PUSH"; then + docker push "$repository:lgsm_debian${SUFFIX}" +fi \ No newline at end of file