diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..7bf05f644d --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,83 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference +version: 2.1 + +orbs: + aws-s3: circleci/aws-s3@2.0.0 + +workflows: + version: 2 + build-deploy: + jobs: + - build-image + - build: + requires: + - build-image + - test: + requires: + - build-image + - deploy: + requires: + - build + - test + # filters: + # branches: + # only: master + +jobs: + build-image: + machine: true + steps: + - checkout + - run: | + echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin + build/install.sh + docker push popcodeorg/popcode:$CIRCLE_BRANCH + if [[ "$CIRCLE_BRANCH" == "master" ]] + then + if [[ -z "$CIRCLE_PR_NUMBER" ]] + then + docker tag popcodeorg/popcode:$CIRCLE_BRANCH popcodeorg/popcode + docker push popcodeorg/popcode + fi + fi + + test: + docker: + - image: popcodeorg/popcode:$CIRCLE_BRANCH + auth: + username: $DOCKER_USER + password: $DOCKER_PASS + environment: + NODE_ENV: test + steps: + - run: yarn test + working_directory: /app + + build: + docker: + - image: popcodeorg/popcode:$CIRCLE_BRANCH + auth: + username: $DOCKER_USER + password: $DOCKER_PASS + environment: + GIT_REVISION: $CIRCLE_SHA1 + NODE_ENV: production + steps: + - run: yarn run gulp build + - persist_to_workspace: + root: . + paths: + - 'dist' + working_directory: /app + + deploy: + docker: + - image: cimg/base:stable + steps: + - attach_workspace: + at: . + - aws-s3/sync: + from: dist + to: 's3://popcode.school/' + arguments: | + --acl public-read diff --git a/build/build.sh b/build/build.sh index eafd9f81f4..0c851b9cdb 100755 --- a/build/build.sh +++ b/build/build.sh @@ -11,8 +11,8 @@ docker run \ --env FIREBASE_CLIENT_ID \ --env FIREBASE_MEASUREMENT_ID \ --env FIREBASE_PROJECT_ID \ - --env GIT_REVISION="$TRAVIS_COMMIT" \ + --env GIT_REVISION="$CIRCLE_SHA1" \ --env MIXPANEL_TOKEN \ - --volume="$TRAVIS_BUILD_DIR/dist:/app/dist" \ + --volume="$(pwd)/dist:/app/dist" \ popcode \ yarn run gulp build diff --git a/build/install.sh b/build/install.sh index 4236052f17..7b8484efd3 100755 --- a/build/install.sh +++ b/build/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -ex @@ -7,5 +7,5 @@ docker build \ --pull \ --force-rm \ --cache-from popcodeorg/popcode:latest \ - --tag popcode \ + --tag popcodeorg/popcode:$CIRCLE_BRANCH \ .