Merge pull request #104 from web-push-libs/circleci

Circleci
This commit is contained in:
JR Conlin 2019-03-13 19:43:22 -07:00 committed by GitHub
commit f6f2b4e986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 12 deletions

88
.circleci/config.yml Normal file
View File

@ -0,0 +1,88 @@
# These environment variables must be set in CircleCI UI
#
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
# DOCKER_USER - login info for docker hub
# DOCKER_PASS
#
version: 2
jobs:
build:
docker:
- image: docker:18.02.0-ce
working_directory: /dockerflow
steps:
# workaround circleci's fallback git's "object not found" error w/ tag
# builds
- run:
name: Install Docker build dependencies
command: apk add --no-cache openssh-client git
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: docker build -t app:build .
# save the built docker container into CircleCI's cache. This is
# required since Workflows do not have the same remote docker instance.
- run:
name: docker save app:build
command: mkdir -p /cache; docker save -o /cache/docker.tar "app:build"
- save_cache:
key: v1-{{ .Branch }}-{{ .Environment.CIRCLE_TAG }}-{{ epoch }}
paths:
- /cache/docker.tar
deploy:
docker:
- image: docker:18.02.0-ce
steps:
- setup_remote_docker
- restore_cache:
key: v1-{{.Branch}}
- run:
name: Restore Docker image cache
command: docker load -i /cache/docker.tar
- run:
name: Deploy to Dockerhub
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
DOCKER_TAG="latest"
fi
if echo "${CIRCLE_BRANCH}" | grep '^feature\..*' > /dev/null; then
DOCKER_TAG="${CIRCLE_BRANCH}"
fi
if [ -n "${CIRCLE_TAG}" ]; then
DOCKER_TAG="$CIRCLE_TAG"
fi
if [ -n "${DOCKER_TAG}" ]; then
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
echo ${DOCKERHUB_REPO}:${DOCKER_TAG}
docker tag app:build ${DOCKERHUB_REPO}:${DOCKER_TAG}
docker images
docker push "${DOCKERHUB_REPO}:${DOCKER_TAG}"
else
echo "Not pushing to dockerhub for tag=${CIRCLE_TAG} branch=${CIRCLE_BRANCH}"
fi
workflows:
version: 2
build-deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- deploy:
requires:
- build
filters:
tags:
only: /.*/

View File

@ -1,12 +0,0 @@
# circle ci file
machine:
post:
- pyenv global 2.7.13 3.5
dependencies:
pre:
- pip install -r test-requirements.txt
test:
override:
- nosetests -v pywebpush