зеркало из https://github.com/mozilla/PollBot.git
circleci: Add v2 config
This commit is contained in:
Родитель
2249bb1c7c
Коммит
b7e600c7de
|
@ -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: /.*/
|
Загрузка…
Ссылка в новой задаче