From a8537f2ff5ccf6cfd3a8259fd5997b34a8d374c1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 2 Aug 2021 19:13:47 -0700 Subject: [PATCH] workflows --- .circleci/config.yml | 68 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2299f77284..20f4523ab1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,12 @@ -version: 2 +version: 2.1 + +executors: + docker-publisher: + environment: + IMAGE_NAME: outline + docker: + - image: circleci/buildpack-deps:stretch + jobs: build: working_directory: ~/outline @@ -40,4 +48,60 @@ jobs: command: yarn test - run: name: build-webpack - command: yarn build:webpack \ No newline at end of file + command: yarn build:webpack + build-image: + executor: docker-publisher + steps: + - checkout + - setup_remote_docker + - run: + name: Build Docker image + command: docker build -t $IMAGE_NAME:latest . + - run: + name: Archive Docker image + command: docker save -o image.tar $IMAGE_NAME + - persist_to_workspace: + root: . + paths: + - ./image.tar + publish-image: + executor: docker-publisher + steps: + - attach_workspace: + at: /tmp/workspace + - setup_remote_docker + - run: + name: Load archived Docker image + command: docker load -i /tmp/workspace/image.tar + - run: + name: Publish Docker Image to Docker Hub + command: | + echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin + IMAGE_TAG=version-${CIRCLE_TAG/v/''} + docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG + docker push $IMAGE_NAME:$IMAGE_TAG + +workflows: + version: 2 + build-and-test: + jobs: + - build + filters: + tags: + ignore: /^v.*/ + build-docker: + jobs: + - build-image: + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ + - publish-image: + requires: + - build-image + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ \ No newline at end of file