summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.circleci/build.sh12
-rw-r--r--.circleci/deploy.sh25
2 files changed, 37 insertions, 0 deletions
diff --git a/.circleci/build.sh b/.circleci/build.sh
new file mode 100644
index 000000000..7d476c85d
--- /dev/null
+++ b/.circleci/build.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -euf -o pipefail
+
+docker build \
+ --build-arg CI="$CI" \
+ --build-arg CIRCLE_SHA1="$CIRCLE_SHA1" \
+ --build-arg CIRCLE_BUILD_URL="$CIRCLE_BUILD_URL" \
+ -t bmo .
+
+docker run --name bmo --entrypoint true bmo
+docker cp bmo:/app/version.json build_info/version.json
diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh
new file mode 100644
index 000000000..3d8a3852f
--- /dev/null
+++ b/.circleci/deploy.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -euf -o pipefail
+
+[[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0
+docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
+
+if [[ "$CIRCLE_BRANCH" == "master" ]]; then
+ TAG="$(cat /app/build_info/tag.txt)"
+ [[ -n "$GITHUB_PERSONAL_TOKEN" ]] || exit 0
+ if [[ -n "$TAG" && -f build_info/publish.txt ]]; then
+ git config credential.helper "cache --timeout 120"
+ git config user.email "$GITHUB_EMAIL"
+ git config user.name "$GITHUB_NAME"
+ git tag $TAG
+ git push https://${GITHUB_PERSONAL_TOKEN}:x-oauth-basic@github.com/$GITHUB_REPO.git $TAG
+ docker tag bmo "$DOCKERHUB_REPO:$TAG"
+ docker push "$DOCKERHUB_REPO:$TAG"
+ fi
+ docker tag bmo "$DOCKERHUB_REPO:latest"
+ docker push "$DOCKERHUB_REPO:latest"
+elif [[ "$CIRCLE_BRANCH" == "development" ]]; then
+ docker tag bmo "$DOCKERHUB_REPO:build-${CIRCLE_BUILD_NUM}"
+ docker push "$DOCKERHUB_REPO:build-${CIRCLE_BUILD_NUM}"
+fi