docker-backuppc/.circleci/config.yml
Adrien Ferrand 2ad8dbf239 Run deploy
2018-11-27 10:46:53 +01:00

78 lines
2.3 KiB
YAML

version: 2
workflows:
version: 2
main-pipeline:
jobs:
- build-n-test:
filters:
tags:
only: /.*/
- deploy:
requires:
- build-n-test
filters:
branches:
only: /^(master|4|3|broken-.*)$/
tags:
only: /.*/
- trigger-dockerhub:
requires:
- build-n-test
filters:
branches:
only: master
jobs:
build-n-test:
machine: true
steps:
- checkout
- run:
name: Build container
command: |
docker pull adferrand/backuppc || true
docker build --pull --cache-from adferrand/backuppc -t adferrand/backuppc .
- run:
name: Test container
command: |
mkdir -p ./bin
curl -fsSL https://goss.rocks/install | GOSS_DST=./bin sh
GOSS_PATH=./bin/goss GOSS_SLEEP=1 GOSS_FILES_PATH=./tests ./bin/dgoss run -e LETSENCRYPT_STAGING=true adferrand/backuppc
- run:
name: Save container
command: |
mkdir -p workspace
docker save adferrand/backuppc | gzip -c -1 > workspace/docker-backuppc.tar.gz
- persist_to_workspace:
root: workspace
paths:
- docker-backuppc.tar.gz
deploy:
machine: true
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Load container
command:
docker load < /tmp/workspace/docker-backuppc.tar.gz
- run:
name: Login to DockerHub
command:
echo "${DOCKER_PASS}" | docker login -u ${DOCKER_USER} --password-stdin
- deploy:
name: Deploy to DockerHub
command: |
if [ ${CIRCLE_BRANCH} = master ]; then DOCKER_TAG=latest; else DOCKER_TAG=${CIRCLE_TAG:-${CIRCLE_BRANCH}}; fi
echo ${DOCKER_TAG}
docker tag adferrand/backuppc adferrand/backuppc:${DOCKER_TAG}
docker push adferrand/backuppc:${DOCKER_TAG}
trigger-dockerhub:
machine: true
steps:
- deploy:
name: Trigger DockerHub build
command: |
curl -H "Content-Type: application/json" --data '{"docker_tag": "master"}' -X POST https://registry.hub.docker.com/u/adferrand/backuppc/trigger/463a9d6d-4293-42bb-861f-72e450a22656/