1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

Merge pull request #268 from mozilla/circleci

Circleci
This commit is contained in:
Adrian Utrilla
2017-10-12 15:04:53 -07:00
committed by GitHub
2 changed files with 58 additions and 0 deletions

25
.circleci/config.yml Normal file
View File

@@ -0,0 +1,25 @@
version: 2
jobs:
build:
working_directory: /go/src/github.com/mozilla/sops
docker:
- image: circleci/golang:1.8
steps:
- checkout
- run:
name: Build Sops
command: make
- setup_remote_docker
- run:
name: Build containers
command: |
docker build -t mozilla/sops .
docker tag mozilla/sops "mozilla/sops:$CIRCLE_SHA1"
- run:
name: Push containers
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./bin/ci/deploy_dockerhub.sh "latest"
./bin/ci/deploy_dockerhub.sh "$CIRCLE_SHA1"
fi

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# THIS IS MEANT TO BE RUN BY CI
set -e
set +x
# Usage: retry MAX CMD...
# Retry CMD up to MAX times. If it fails MAX times, returns failure.
# Example: retry 3 docker push "mozilla/sops:$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
}
if [[ "$DOCKER_DEPLOY" == "true" ]]; then
# configure docker creds
retry 3 docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
# docker tag and push git branch to dockerhub
if [ -n "$1" ]; then
retry 3 docker push "mozilla/sops:$1" ||
(echo "Couldn't push mozilla/sops:$1" && false)
echo "Pushed mozilla/sops:$1"
fi
fi