@@ -16,19 +16,21 @@ cd "$VERSION_SHORT" || exit 1
16
16
VERSION=$( grep -oP ' [0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
17
17
DOCKER_REPO=factoriotools/factorio
18
18
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 "
21
23
else
22
24
if [[ -n ${CI:- } ]]; then
23
25
# 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
25
27
TAGS=" -t $DOCKER_REPO :$VERSION -t $DOCKER_REPO :$VERSION_SHORT "
26
28
# 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 "
29
31
# 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 "
32
34
fi
33
35
else
34
36
# we are not in CI and tag version and version short
@@ -58,13 +60,13 @@ docker images
58
60
59
61
# remove -1 from incremental tag
60
62
# 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 % -* }
63
65
fi
64
66
65
67
# only push when:
66
68
# 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 :- } == " " ]] ||
68
70
# or we are not in CI
69
71
[[ -z ${CI:- } ]]; then
70
72
@@ -73,18 +75,18 @@ if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_PULL_REQUEST_BRANCH:-
73
75
fi
74
76
75
77
# 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 "
78
80
fi
79
81
80
82
# push an incremental tag
81
83
# 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 "
84
86
fi
85
87
86
88
# 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
88
90
docker push " $DOCKER_REPO :$VERSION "
89
91
docker push " $DOCKER_REPO :$VERSION_SHORT "
90
92
fi
0 commit comments