2018-07-03 10:04:21 -07:00
|
|
|
#!/bin/bash -e
|
2018-04-26 11:35:07 -07:00
|
|
|
|
|
|
|
login() {
|
|
|
|
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
|
|
|
}
|
|
|
|
|
2018-07-03 09:22:45 -07:00
|
|
|
tag_push() {
|
|
|
|
docker tag $DOCKER_USERNAME/zigbee2mqtt:$1 $DOCKER_USERNAME/zigbee2mqtt:$2
|
|
|
|
docker push $DOCKER_USERNAME/zigbee2mqtt:$2
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:35:07 -07:00
|
|
|
build_and_push() {
|
2018-06-15 15:10:08 -07:00
|
|
|
docker build --build-arg COMMIT=$(git rev-parse --short HEAD) -t $DOCKER_USERNAME/zigbee2mqtt:$1 -f $2 .
|
2018-04-26 11:41:08 -07:00
|
|
|
docker push $DOCKER_USERNAME/zigbee2mqtt:$1
|
2018-04-26 11:35:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# Only update docker images if on master branch and not pull request
|
2018-07-03 10:07:15 -07:00
|
|
|
echo "==="
|
|
|
|
echo $TRAVIS_BRANCH
|
|
|
|
echo $TRAVIS_PULL_REQUEST
|
|
|
|
echo $TRAVIS_TAG
|
|
|
|
echo "==="
|
2018-07-03 09:22:45 -07:00
|
|
|
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ ! -z ${TRAVIS_TAG+x} ]
|
2018-04-26 11:35:07 -07:00
|
|
|
then
|
2018-05-09 13:15:59 -07:00
|
|
|
echo "Updating docker images for master branch!"
|
2018-04-26 11:35:07 -07:00
|
|
|
login
|
2018-05-09 13:15:59 -07:00
|
|
|
build_and_push latest docker/Dockerfile.amd64
|
2018-07-03 09:22:45 -07:00
|
|
|
tag_push latest "$TRAVIS_TAG"
|
|
|
|
build_and_push "$TRAVIS_TAG-arm32v6" docker/Dockerfile.arm32v6
|
|
|
|
build_and_push "$TRAVIS_TAG-arm64v8" docker/Dockerfile.arm64v8
|
2018-05-09 13:15:59 -07:00
|
|
|
elif [ "$TRAVIS_BRANCH" = "dev" -a "$TRAVIS_PULL_REQUEST" = "false" ]
|
|
|
|
then
|
|
|
|
echo "Updating docker images for dev branch!"
|
|
|
|
login
|
|
|
|
build_and_push latest-dev docker/Dockerfile.amd64
|
|
|
|
build_and_push arm32v6-dev docker/Dockerfile.arm32v6
|
|
|
|
build_and_push arm64v8-dev docker/Dockerfile.arm64v8
|
2018-04-26 11:35:07 -07:00
|
|
|
else
|
2018-05-09 13:15:59 -07:00
|
|
|
echo "Not updating docker images, triggered by pull request or not on master/dev branch"
|
2018-04-26 11:35:07 -07:00
|
|
|
fi
|