mirror of https://github.com/tidwall/tile38.git
wip - docker push file
This commit is contained in:
parent
7fa632a54f
commit
753b22d4a8
|
@ -26,8 +26,9 @@ jobs:
|
|||
- name: Test
|
||||
run: make test
|
||||
|
||||
# - name: Test
|
||||
# run: ./scripts/test.sh
|
||||
|
||||
# - name: Build
|
||||
# run: make tile38-server
|
||||
- name: Docker push
|
||||
env:
|
||||
DOCKER_LOGIN: tidwall
|
||||
DOCKER_USER: tile38
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: ./scripts/docker-push.sh
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
cd $(dirname "${BASH_SOURCE[0]}")/..
|
||||
|
||||
|
||||
if [ "$DOCKER_USER" == "" ]; then
|
||||
echo "Not pushing, DOCKER_USER not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$DOCKER_LOGIN" == "" ]; then
|
||||
echo "Not pushing, DOCKER_LOGIN not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$DOCKER_PASSWORD" == "" ]; then
|
||||
echo "Not pushing, DOCKER_PASSWORD not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# GIT_BRANCH is the current branch name
|
||||
export GIT_BRANCH=$(git branch --show-current)
|
||||
# GIT_VERSION - always the last verison number, like 1.12.1.
|
||||
export GIT_VERSION=$(git describe --tags --abbrev=0)
|
||||
# GIT_COMMIT_SHORT - the short git commit number, like a718ef0.
|
||||
export GIT_COMMIT_SHORT=$(git rev-parse --short HEAD)
|
||||
# DOCKER_REPO - the base repository name to push the docker build to.
|
||||
export DOCKER_REPO=$DOCKER_USER/tile38
|
||||
|
||||
if [ "$GIT_BRANCH" != "master" ]; then
|
||||
# only the master branch will work
|
||||
echo "Not pushing, not on master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
push(){
|
||||
docker tag $DOCKER_REPO:$GIT_COMMIT_SHORT $DOCKER_REPO:$1
|
||||
docker push $DOCKER_REPO:$1
|
||||
echo "Pushed $DOCKER_REPO:$1"
|
||||
}
|
||||
|
||||
# docker login
|
||||
echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin
|
||||
# build the docker image
|
||||
docker build -f Dockerfile -t $DOCKER_REPO:$GIT_COMMIT_SHORT .
|
||||
if [ "$(curl -s https://hub.docker.com/v2/repositories/$DOCKER_REPO/tags/$GIT_VERSION/ | grep "digest")" == "" ]; then
|
||||
# push the newest tag
|
||||
push "$GIT_VERSION"
|
||||
push "latest"
|
||||
fi
|
||||
push "edge"
|
|
@ -1,35 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
cd $(dirname "${BASH_SOURCE[0]}")/..
|
||||
|
||||
# GIT_VERSION - always the last verison number, like 1.12.1.
|
||||
export GIT_VERSION=$(git describe --tags --abbrev=0)
|
||||
# GIT_COMMIT_SHORT - the short git commit number, like a718ef0.
|
||||
export GIT_COMMIT_SHORT=$(git rev-parse --short HEAD)
|
||||
# DOCKER_REPO - the base repository name to push the docker build to.
|
||||
export DOCKER_REPO=$DOCKER_USER/tile38
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
# never push from a pull request
|
||||
echo "Not pushing, on a PR or not running in Travis CI"
|
||||
elif [ "$TRAVIS_BRANCH" != "master" ]; then
|
||||
# only the master branch will work
|
||||
echo "Not pushing, not on master"
|
||||
else
|
||||
push(){
|
||||
docker tag $DOCKER_REPO:$GIT_COMMIT_SHORT $DOCKER_REPO:$1
|
||||
docker push $DOCKER_REPO:$1
|
||||
echo "Pushed $DOCKER_REPO:$1"
|
||||
}
|
||||
# docker login
|
||||
echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin
|
||||
# build the docker image
|
||||
docker build -f Dockerfile -t $DOCKER_REPO:$GIT_COMMIT_SHORT .
|
||||
if [ "$(curl -s https://hub.docker.com/v2/repositories/$DOCKER_REPO/tags/$GIT_VERSION/ | grep "digest")" == "" ]; then
|
||||
# push the newest tag
|
||||
push "$GIT_VERSION"
|
||||
push "latest"
|
||||
fi
|
||||
push "edge"
|
||||
fi
|
Loading…
Reference in New Issue