mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-10 19:15:30 +02:00
Advance CI features (#245)
* Build feature branches with branch tag * Build short and long image tag * Add latest and stable tag, made moving repos easier * Only push tags to registry * Only build tags that where changed * Fix if and quoting, push $VERSION_SHORT * Update MicroBadger with Webhook, closes #251 * Quote vars * Set tag on PR, too * Switch to hadolint docker image due to PR not having enviroment variables and I don't want to commit my token in the script * Only push image on master
This commit is contained in:
47
build.sh
47
build.sh
@ -1,12 +1,47 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
set -eox pipefail
|
||||
|
||||
if [ -z "$1" ] ; then
|
||||
echo "Usage: ./build.sh \$VERSION"
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: ./build.sh \$VERSION_SHORT"
|
||||
else
|
||||
VERSION="$1"
|
||||
VERSION_SHORT="$1"
|
||||
fi
|
||||
|
||||
cd "$VERSION" || exit
|
||||
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' "$VERSION_SHORT/Dockerfile" | head -1)
|
||||
DOCKER_REPO=factoriotools/docker_factorio_server
|
||||
cd "$VERSION_SHORT" || exit
|
||||
|
||||
docker build . -t "factoriotools/docker_factorio_server:$VERSION"
|
||||
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
|
||||
TAG="$TRAVIS_PULL_REQUEST_SLUG"
|
||||
else
|
||||
if [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
TAG="$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
else
|
||||
TAG="$TRAVIS_BRANCH"
|
||||
fi
|
||||
|
||||
if [ -n "$EXTRA_TAG" ]; then
|
||||
TAG="$TAG -t $DOCKER_REPO:$EXTRA_TAG"
|
||||
fi
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker build . -t $DOCKER_REPO:$TAG
|
||||
|
||||
docker images
|
||||
|
||||
if [ "$(dirname "$(git diff --name-only HEAD^)" | head -1)" == "$VERSION" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
docker push "$DOCKER_REPO:latest"
|
||||
|
||||
if [ -n "$EXTRA_TAG" ]; then
|
||||
docker push "$DOCKER_REPO:$EXTRA_TAG"
|
||||
fi
|
||||
|
||||
if [ -n "$TRAVIS_TAG" ]; then
|
||||
docker push "$DOCKER_REPO:$VERSION"
|
||||
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
||||
fi
|
||||
|
||||
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=
|
||||
fi
|
||||
|
Reference in New Issue
Block a user