Splits the deploy-docker.sh into build and deploy parts
This commit is contained in:
parent
53154c0cf2
commit
7b75f6c6d4
4 changed files with 91 additions and 64 deletions
|
@ -1,64 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
scripts="$PWD/ci"
|
||||
TRAVIS_BRANCH=$(git branch | cut -f2 -d' ')
|
||||
tags=()
|
||||
if [ -n "$TRAVIS_TAG" ]; then
|
||||
tags+=("$TRAVIS_TAG")
|
||||
elif [ -n "$TRAVIS_BRANCH" ]; then
|
||||
TRAVIS_TAG=$TRAVIS_BRANCH
|
||||
tags+=("$TRAVIS_BRANCH")
|
||||
fi
|
||||
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
|
||||
echo "Live"
|
||||
network_tag_suffix=''
|
||||
network="live"
|
||||
elif [[ "$GITHUB_WORKFLOW" = "Beta" ]]; then
|
||||
echo "Beta"
|
||||
network_tag_suffix="-beta"
|
||||
network="beta"
|
||||
elif [[ "$GITHUB_WORKFLOW" = "Test" ]]; then
|
||||
echo "Test"
|
||||
network_tag_suffix="-test"
|
||||
network="test"
|
||||
fi
|
||||
if [[ "$GITHUB_WORKFLOW" != "Develop" ]]; then
|
||||
docker_image_name="nanocurrency/nano${network_tag_suffix}"
|
||||
ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}"
|
||||
"$scripts"/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" --build-arg NETWORK="$network" --build-arg CI_BUILD=true --build-arg TRAVIS_TAG="$TRAVIS_TAG"
|
||||
for tag in "${tags[@]}"; do
|
||||
# Sanitize docker tag
|
||||
# https://docs.docker.com/engine/reference/commandline/tag/
|
||||
tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)"
|
||||
if [ "$tag" != "latest" ]; then
|
||||
docker tag "$docker_image_name" "${docker_image_name}:$tag"
|
||||
docker tag "$ghcr_image_name" "${ghcr_image_name}:$tag"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$DOCKER_PASSWORD" ]; then
|
||||
echo "$DOCKER_PASSWORD" | docker login -u nanoreleaseteam --password-stdin
|
||||
if [[ "$GITHUB_WORKFLOW" = "Develop" ]]; then
|
||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:base"
|
||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:gcc"
|
||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang-6"
|
||||
echo "Deployed nano-env"
|
||||
exit 0
|
||||
else
|
||||
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
|
||||
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none|latest")
|
||||
else
|
||||
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none")
|
||||
fi
|
||||
for a in $tags; do
|
||||
"$scripts"/custom-timeout.sh 30 docker push "$a"
|
||||
done
|
||||
echo "$docker_image_name with tags ${tags//$'\n'/' '} deployed"
|
||||
fi
|
||||
else
|
||||
echo "\$DOCKER_PASSWORD environment variable required"
|
||||
exit 0
|
||||
fi
|
8
ci/actions/linux/docker-build.sh
Normal file
8
ci/actions/linux/docker-build.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
|
||||
|
||||
docker_build
|
8
ci/actions/linux/docker-deploy.sh
Normal file
8
ci/actions/linux/docker-deploy.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
|
||||
|
||||
docker_deploy
|
75
ci/actions/linux/docker-impl/docker-common.sh
Executable file
75
ci/actions/linux/docker-impl/docker-common.sh
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -a
|
||||
|
||||
scripts="$PWD/ci"
|
||||
TRAVIS_BRANCH=$(git branch | cut -f2 -d' ')
|
||||
tags=()
|
||||
if [ -n "$TRAVIS_TAG" ]; then
|
||||
tags+=("$TRAVIS_TAG")
|
||||
elif [ -n "$TRAVIS_BRANCH" ]; then
|
||||
TRAVIS_TAG=$TRAVIS_BRANCH
|
||||
tags+=("$TRAVIS_BRANCH")
|
||||
fi
|
||||
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
|
||||
echo "Live"
|
||||
network_tag_suffix=''
|
||||
network="live"
|
||||
elif [[ "$GITHUB_WORKFLOW" = "Beta" ]]; then
|
||||
echo "Beta"
|
||||
network_tag_suffix="-beta"
|
||||
network="beta"
|
||||
elif [[ "$GITHUB_WORKFLOW" = "Test" ]]; then
|
||||
echo "Test"
|
||||
network_tag_suffix="-test"
|
||||
network="test"
|
||||
fi
|
||||
|
||||
if [[ "$GITHUB_WORKFLOW" != "Develop" ]]; then
|
||||
docker_image_name="nanocurrency/nano${network_tag_suffix}"
|
||||
fi
|
||||
|
||||
docker_build()
|
||||
{
|
||||
if [[ "$GITHUB_WORKFLOW" != "Develop" ]]; then
|
||||
ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}"
|
||||
"$scripts"/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" --build-arg NETWORK="$network" --build-arg CI_BUILD=true --build-arg TRAVIS_TAG="$TRAVIS_TAG"
|
||||
for tag in "${tags[@]}"; do
|
||||
# Sanitize docker tag
|
||||
# https://docs.docker.com/engine/reference/commandline/tag/
|
||||
tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)"
|
||||
if [ "$tag" != "latest" ]; then
|
||||
docker tag "$docker_image_name" "${docker_image_name}:$tag"
|
||||
docker tag "$ghcr_image_name" "${ghcr_image_name}:$tag"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
docker_deploy()
|
||||
{
|
||||
if [ -n "$DOCKER_PASSWORD" ]; then
|
||||
echo "$DOCKER_PASSWORD" | docker login -u nanoreleaseteam --password-stdin
|
||||
if [[ "$GITHUB_WORKFLOW" = "Develop" ]]; then
|
||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:base"
|
||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:gcc"
|
||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang-6"
|
||||
echo "Deployed nano-env"
|
||||
exit 0
|
||||
else
|
||||
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
|
||||
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none|latest")
|
||||
else
|
||||
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none")
|
||||
fi
|
||||
for a in $tags; do
|
||||
"$scripts"/custom-timeout.sh 30 docker push "$a"
|
||||
done
|
||||
echo "$docker_image_name with tags ${tags//$'\n'/' '} deployed"
|
||||
fi
|
||||
else
|
||||
echo "\$DOCKER_PASSWORD environment variable required"
|
||||
exit 0
|
||||
fi
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue