Add a real deploy step
This commit is contained in:
Родитель
a845497a5d
Коммит
0600cae79c
|
@ -38,10 +38,10 @@ jobs:
|
|||
command: docker build -t mozilla/ci-base-<< parameters.imageName >> << parameters.imageName >>/
|
||||
|
||||
- run:
|
||||
name: Dummy Deploy
|
||||
name: Deploy
|
||||
command: |
|
||||
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
||||
echo TODO implement deployment of << parameters.imageName >>
|
||||
./bin/push-image.sh mozilla/ci-base-<< parameters.imageName >>
|
||||
fi
|
||||
|
||||
workflows:
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
image=$1
|
||||
|
||||
# Usage: retry MAX CMD...
|
||||
# Retry CMD up to MAX times. If it fails MAX times, returns failure.
|
||||
# Example: retry 3 docker push "mozilla/normandy:$TAG"
|
||||
function retry() {
|
||||
max=$1
|
||||
shift
|
||||
count=1
|
||||
until "$@"; do
|
||||
count=$((count + 1))
|
||||
if [[ $count -gt $max ]]; then
|
||||
return 1
|
||||
fi
|
||||
echo "$count / $max"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "$DOCKER_PASSWORD" | docker login --username="$DOCKER_USERNAME" --password-stdin
|
||||
|
||||
versioned="${image}:latest"
|
||||
docker tag "${image}" "${versioned}" || (echo "Couldn't re-tag ${image} as ${versioned}" && false)
|
||||
retry 3 docker push "${versioned}" || (echo "Couldn't push ${versioned}" && false)
|
||||
|
||||
echo "Pushed ${versioned}"
|
Загрузка…
Ссылка в новой задаче