This commit is contained in:
Philip Cristiano 2018-04-16 10:30:28 -04:00
Родитель 2249bb1c7c
Коммит b7e600c7de
1 изменённых файлов: 74 добавлений и 0 удалений

74
.circleci/config.yml Normal file
Просмотреть файл

@ -0,0 +1,74 @@
version: 2
jobs:
build:
machine: true
working_directory: ~/PollBot
steps:
- run:
name: Install essential packages
command: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl build-essential make git pigz
- checkout
- run:
name: Create version.json
command: |
# create a version.json per https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
"$CIRCLE_SHA1" \
"`git describe`" \
"$CIRCLE_PROJECT_USERNAME" \
"$CIRCLE_PROJECT_REPONAME" \
"$CIRCLE_BUILD_URL" > version.json
- store_artifacts:
path: version.json
- run:
name: Build Docker image
command: |
docker info
docker build --pull -t app .
- run:
name: Run tests
command: docker run -it app /bin/bash /app/scripts/run-tests.sh
- deploy:
name: Push to Dockerhub
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
DOCKER_TAG="${DOCKERHUB_REPO}:latest"
elif [ -z "${CIRCLE_TAG}" ]; then
echo "Not a tag or master branch build"
exit 0
else
DOCKER_TAG="${DOCKERHUB_REPO}:${CIRCLE_TAG}"
fi
echo "${DOCKER_TAG}"
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker tag app "${DOCKER_TAG}"
docker images
docker push "${DOCKER_TAG}"
workflows:
version: 2
# workflow jobs are _not_ run in tag builds by default
# we use filters to whitelist jobs that should be run for tags
# workflow jobs are run in _all_ branch builds by default
# we use filters to blacklist jobs that shouldn't be run for a branch
# see: https://circleci.com/docs/2.0/workflows/#git-tag-job-execution
build-test-push:
jobs:
- build:
filters:
tags:
only: /.*/