docker-backuppc/.circleci/config.yml

82 lines
2.4 KiB
YAML
Raw Normal View History

2018-12-06 13:59:12 +01:00
# Test
2018-09-16 11:39:13 +02:00
version: 2
2018-09-27 11:45:19 +02:00
workflows:
version: 2
main-pipeline:
jobs:
- build-n-test:
filters:
2018-12-06 13:58:34 +01:00
branches:
only: /.*/
2018-09-27 11:45:19 +02:00
tags:
2018-10-09 17:28:53 +02:00
only: /.*/
2018-09-27 11:45:19 +02:00
- deploy:
requires:
- build-n-test
filters:
branches:
only: /^(master|4|3)$/
tags:
2018-10-09 17:28:53 +02:00
only: /.*/
2018-09-27 11:45:19 +02:00
- trigger-dockerhub:
requires:
- build-n-test
filters:
branches:
only: master
2018-09-16 11:39:13 +02:00
jobs:
build-n-test:
2018-09-16 12:29:15 +02:00
machine: true
2018-09-16 11:39:13 +02:00
steps:
- checkout
- run:
name: Build container
2018-09-16 22:16:21 +02:00
command: |
docker pull adferrand/backuppc || true
2018-09-17 10:22:07 +02:00
docker build --pull --cache-from adferrand/backuppc -t adferrand/backuppc .
2018-09-16 11:39:13 +02:00
- 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
2018-09-16 12:03:05 +02:00
command: |
mkdir -p workspace
2018-09-27 11:46:01 +02:00
docker save adferrand/backuppc | gzip -c -1 > workspace/docker-backuppc.tar.gz
2018-09-16 11:39:13 +02:00
- persist_to_workspace:
2018-09-16 12:03:05 +02:00
root: workspace
2018-09-16 11:39:13 +02:00
paths:
2018-09-27 11:46:01 +02:00
- docker-backuppc.tar.gz
2018-09-16 11:39:13 +02:00
deploy:
2018-09-16 12:29:15 +02:00
machine: true
2018-09-16 11:39:13 +02:00
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Load container
2018-09-16 11:39:13 +02:00
command:
2018-09-27 11:46:01 +02:00
docker load < /tmp/workspace/docker-backuppc.tar.gz
2018-09-16 22:19:47 +02:00
- run:
name: Login to DockerHub
2018-09-16 22:19:47 +02:00
command:
2018-09-16 22:23:24 +02:00
echo "${DOCKER_PASS}" | docker login -u ${DOCKER_USER} --password-stdin
- deploy:
name: Deploy to DockerHub
2018-09-16 14:57:29 +02:00
command: |
2018-09-16 22:10:35 +02:00
if [ ${CIRCLE_BRANCH} = master ]; then DOCKER_TAG=latest; else DOCKER_TAG=${CIRCLE_TAG:-${CIRCLE_BRANCH}}; fi
2018-11-27 00:58:29 +01:00
echo ${DOCKER_TAG}
2018-09-16 22:10:35 +02:00
docker tag adferrand/backuppc adferrand/backuppc:${DOCKER_TAG}
docker push adferrand/backuppc:${DOCKER_TAG}
2018-09-27 11:45:19 +02:00
trigger-dockerhub:
machine: true
steps:
- deploy:
2018-09-27 11:45:19 +02:00
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/