mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
25
.circleci/config.yml
Normal file
25
.circleci/config.yml
Normal 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
|
||||
|
||||
33
bin/ci/deploy_dockerhub.sh
Normal file
33
bin/ci/deploy_dockerhub.sh
Normal 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
|
||||
Reference in New Issue
Block a user