@@ -16,19 +16,21 @@ cd "$VERSION_SHORT" || exit 1
1616VERSION=$( grep -oP ' [0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
1717DOCKER_REPO=factoriotools/factorio
1818
19- if [[ ${TRAVIS_PULL_REQUEST:- } == true ]]; then
20- TAGS=" $DOCKER_REPO :$TRAVIS_PULL_REQUEST_SLUG "
19+ BRANCH=${GITHUB_REF# refs/ heads/ }
20+
21+ if [[ -n ${GITHUB_BASE_REF:- } ]]; then
22+ TAGS=" $DOCKER_REPO :$GITHUB_BASE_REF "
2123else
2224 if [[ -n ${CI:- } ]]; then
2325 # we are either on master or on a tag build
24- if [[ ${TRAVIS_BRANCH :- } == master || ${TRAVIS_BRANCH :- } == " $VERSION " ]]; then
26+ if [[ ${BRANCH :- } == master || ${BRANCH :- } == " $VERSION " ]]; then
2527 TAGS=" -t $DOCKER_REPO :$VERSION -t $DOCKER_REPO :$VERSION_SHORT "
2628 # we are on an incremental build of a tag
27- elif [[ $VERSION == " ${TRAVIS_BRANCH % -* } " ]]; then
28- TAGS=" -t $DOCKER_REPO :$TRAVIS_BRANCH -t $DOCKER_REPO :$VERSION -t $DOCKER_REPO :$VERSION_SHORT "
29+ elif [[ $VERSION == " ${BRANCH % -* } " ]]; then
30+ TAGS=" -t $DOCKER_REPO :$BRANCH -t $DOCKER_REPO :$VERSION -t $DOCKER_REPO :$VERSION_SHORT "
2931 # we build a other branch than master and exclude dependabot branches from tags cause the / is not supported by docker
30- elif [[ -n ${TRAVIS_BRANCH :- } && ! $TRAVIS_BRANCH =~ " /" ]]; then
31- TAGS=" -t $DOCKER_REPO :$TRAVIS_BRANCH "
32+ elif [[ -n ${BRANCH :- } && ! $BRANCH =~ " /" ]]; then
33+ TAGS=" -t $DOCKER_REPO :$BRANCH "
3234 fi
3335 else
3436 # we are not in CI and tag version and version short
@@ -58,13 +60,13 @@ docker images
5860
5961# remove -1 from incremental tag
6062# eg before: 0.18.24-1, after 0.18.24
61- if [[ ${TRAVIS_BRANCH :- } ]]; then
62- TRAVIS_BRANCH_VERSION =${TRAVIS_BRANCH % -* }
63+ if [[ ${BRANCH :- } ]]; then
64+ BRANCH_VERSION =${BRANCH % -* }
6365fi
6466
6567# only push when:
6668# or we build a tag and we don't build a PR
67- if [[ $VERSION == " ${TRAVIS_BRANCH_VERSION :- } " && ${TRAVIS_PULL_REQUEST_BRANCH :- } == " " ]] ||
69+ if [[ $VERSION == " ${BRANCH_VERSION :- } " && ${GITHUB_BASE_REF :- } == " " ]] ||
6870 # or we are not in CI
6971 [[ -z ${CI:- } ]]; then
7072
@@ -73,18 +75,18 @@ if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_PULL_REQUEST_BRANCH:-
7375 fi
7476
7577 # push a tag on a branch other than master except dependabot branches cause docker does not support /
76- if [[ -n ${TRAVIS_BRANCH :- } && $VERSION != " ${TRAVIS_BRANCH_VERSION :- } " && ${TRAVIS_BRANCH :- } != " master" && ! ${TRAVIS_BRANCH :- } =~ " /" ]]; then
77- docker push " $DOCKER_REPO :$TRAVIS_BRANCH "
78+ if [[ -n ${BRANCH :- } && $VERSION != " ${BRANCH_VERSION :- } " && ${BRANCH :- } != " master" && ! ${BRANCH :- } =~ " /" ]]; then
79+ docker push " $DOCKER_REPO :$BRANCH "
7880 fi
7981
8082 # push an incremental tag
8183 # eg 0.18.24-1
82- if [[ $VERSION == " ${TRAVIS_BRANCH_VERSION :- } " ]]; then
83- docker push " $DOCKER_REPO :$TRAVIS_BRANCH "
84+ if [[ $VERSION == " ${BRANCH_VERSION :- } " ]]; then
85+ docker push " $DOCKER_REPO :$BRANCH "
8486 fi
8587
8688 # only push on tags or when manually running the script
87- if [[ -n ${TRAVIS_TAG :- } || -z ${CI:- } ]]; then
89+ if [[ -n ${GITHUB_BASE_REF :- } || -z ${CI:- } ]]; then
8890 docker push " $DOCKER_REPO :$VERSION "
8991 docker push " $DOCKER_REPO :$VERSION_SHORT "
9092 fi
0 commit comments