From 064fe66a9adb8cae0dda27e44275ebf1f69cfa83 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Tue, 2 Mar 2021 06:26:41 -0500 Subject: [PATCH 01/16] Add .circleci/config.yml --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..6f98693add --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,13 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference +version: 2.1 +# Use a package of configuration called an orb. +orbs: + # Declare a dependency on the welcome-orb + welcome: circleci/welcome-orb@0.4.1 +# Orchestrate or schedule a set of jobs +workflows: + # Name the workflow "welcome" + welcome: + # Run the welcome/run job in its own container + jobs: + - welcome/run From 048496277d60bc144fea330499799c4767967991 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Thu, 4 Mar 2021 06:08:50 -0500 Subject: [PATCH 02/16] Build and run with Docker --- .circleci/config.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f98693add..3a5dba1de5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,13 +1,10 @@ # Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference version: 2.1 -# Use a package of configuration called an orb. -orbs: - # Declare a dependency on the welcome-orb - welcome: circleci/welcome-orb@0.4.1 -# Orchestrate or schedule a set of jobs -workflows: - # Name the workflow "welcome" - welcome: - # Run the welcome/run job in its own container - jobs: - - welcome/run +jobs: + build: + machine: true + steps: + - checkout + - run: build/install.sh + - run: build/build.sh + - run: build/test.sh From 0fe4b8572c7e4637d5a98a8e113b2380092aeeef Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Fri, 5 Mar 2021 06:25:22 -0500 Subject: [PATCH 03/16] See if artifacts survive between jobs --- .circleci/config.yml | 22 +++++++++++++++++++++- build/build.sh | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3a5dba1de5..468a5ceed2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,10 +1,30 @@ # 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 + - deploy: + requires: + - build + # filters: + # branches: + # only: master + jobs: build: machine: true steps: - checkout - run: build/install.sh + #- run: build/test.sh - run: build/build.sh - - run: build/test.sh + deploy: + machine: true + steps: + - run: ls -l dist diff --git a/build/build.sh b/build/build.sh index eafd9f81f4..e474d5dcb1 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="./dist:/app/dist" \ popcode \ yarn run gulp build From fbbc677f523a3b4a1d43174c9d63ffeeae808c7f Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Fri, 5 Mar 2021 06:29:46 -0500 Subject: [PATCH 04/16] Absolute path --- build/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.sh b/build/build.sh index e474d5dcb1..0c851b9cdb 100755 --- a/build/build.sh +++ b/build/build.sh @@ -13,6 +13,6 @@ docker run \ --env FIREBASE_PROJECT_ID \ --env GIT_REVISION="$CIRCLE_SHA1" \ --env MIXPANEL_TOKEN \ - --volume="./dist:/app/dist" \ + --volume="$(pwd)/dist:/app/dist" \ popcode \ yarn run gulp build From b07e26ba1163dfd16c96bcddccb2442af6b4cba5 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Fri, 5 Mar 2021 08:37:37 -0500 Subject: [PATCH 05/16] Copy built files via workspace --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 468a5ceed2..c845c70ad6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,13 @@ jobs: - run: build/install.sh #- run: build/test.sh - run: build/build.sh + - persist_to_workspace: + root: . + paths: + - 'dist' deploy: machine: true steps: + - attach_workspace: + at: . - run: ls -l dist From a0ec167192d583cf6dc652249f8bc7f484f67b12 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 05:52:43 -0500 Subject: [PATCH 06/16] Push image to Docker Hub, then run other steps on it directly --- .circleci/config.yml | 49 +++++++++++++++++++++++++++++++------------- build/install.sh | 2 +- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c845c70ad6..a5c9afb788 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,29 +8,50 @@ workflows: version: 2 build-deploy: jobs: - - build + - build-image + - build: + requires: + - build-image + - test: + requires: + - build-image - deploy: requires: - build + - test # filters: # branches: # only: master jobs: - build: + build-image: machine: true steps: - checkout - - run: build/install.sh - #- run: build/test.sh - - run: build/build.sh - - persist_to_workspace: - root: . - paths: - - 'dist' - deploy: - machine: true + - run: | + echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin + build/install.sh + docker push popcodeorg/popcode:$CIRCLE_BRANCH + test: + docker: + - image: popcodeorg/popcode:$CIRCLE_BRANCH + auth: + username: $DOCKER_USER + password: $DOCKER_PASS + environment: + NODE_ENV: test steps: - - attach_workspace: - at: . - - run: ls -l dist + - run: yarn test + # build: + # steps: + # - run: build/build.sh + # - persist_to_workspace: + # root: . + # paths: + # - 'dist' + # deploy: + # machine: true + # steps: + # - attach_workspace: + # at: . + # - run: ls -l dist diff --git a/build/install.sh b/build/install.sh index 4236052f17..13de5d7b6c 100755 --- a/build/install.sh +++ b/build/install.sh @@ -7,5 +7,5 @@ docker build \ --pull \ --force-rm \ --cache-from popcodeorg/popcode:latest \ - --tag popcode \ + --tag popcodeorg/popcode:$CIRCLE_BRANCH \ . From 9d2a1ec0b7bb6e14e9635ed818adf1d99c444d8c Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 05:53:41 -0500 Subject: [PATCH 07/16] Comment out more stuff --- .circleci/config.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a5c9afb788..3cb7ee23c4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,19 +9,19 @@ workflows: build-deploy: jobs: - build-image - - build: - requires: - - build-image + # - build: + # requires: + # - build-image - test: requires: - build-image - - deploy: - requires: - - build - - test - # filters: - # branches: - # only: master + # - deploy: + # requires: + # - build + # - test + # filters: + # branches: + # only: master jobs: build-image: From 1521b2c175d82ed63892dd24308c063dd045eef2 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 06:01:55 -0500 Subject: [PATCH 08/16] Add working_directory --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3cb7ee23c4..f251bcbf26 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,6 +42,7 @@ jobs: NODE_ENV: test steps: - run: yarn test + working_directory: /app # build: # steps: # - run: build/build.sh From 6bf3e182fe3daa64ea2acf3dc7945161477ebcbc Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 06:23:43 -0500 Subject: [PATCH 09/16] Build and dry-run deploy --- .circleci/config.yml | 60 +++++++++++++++++++++++++++++--------------- build/install.sh | 2 +- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f251bcbf26..4159bc117b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,16 +9,16 @@ workflows: build-deploy: jobs: - build-image - # - build: - # requires: - # - build-image + - build: + requires: + - build-image - test: requires: - build-image - # - deploy: - # requires: - # - build - # - test + - deploy: + requires: + - build + - test # filters: # branches: # only: master @@ -32,6 +32,13 @@ jobs: echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin build/install.sh docker push popcodeorg/popcode:$CIRCLE_BRANCH + if [[ "$CIRCLE_BRANCH" == "master" ]] + if [[ -z "$CIRCLE_PR_NUMBER" ]] + docker tag popcodeorg/popcode:$CIRCLE_BRANCH popcodeorg/popcode + docker push popcodeorg/popcode + fi + fi + test: docker: - image: popcodeorg/popcode:$CIRCLE_BRANCH @@ -43,16 +50,29 @@ jobs: steps: - run: yarn test working_directory: /app - # build: - # steps: - # - run: build/build.sh - # - persist_to_workspace: - # root: . - # paths: - # - 'dist' - # deploy: - # machine: true - # steps: - # - attach_workspace: - # at: . - # - run: ls -l dist + + build: + docker: + - image: popcodeorg/popcode:$CIRCLE_BRANCH + auth: + username: $DOCKER_USER + password: $DOCKER_PASS + environment: + GIT_REVISION: $CIRCLE_SHA1 + steps: + - run: yarn run gulp build + - persist_to_workspace: + root: . + paths: + - 'dist' + + deploy: + docker: + - image: popcodeorg/popcode:$CIRCLE_BRANCH + auth: + username: $DOCKER_USER + password: $DOCKER_PASS + steps: + - attach_workspace: + at: . + - run: ls -l dist diff --git a/build/install.sh b/build/install.sh index 13de5d7b6c..7b8484efd3 100755 --- a/build/install.sh +++ b/build/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -ex From 73bdce152e2c64d95d65addf0c1dda7bc5698bd4 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 06:33:22 -0500 Subject: [PATCH 10/16] thens --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4159bc117b..8c5a6ec938 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,9 @@ jobs: 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 From 552481d92f5be308810405749f5e89d33da2f9f9 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 07:04:31 -0500 Subject: [PATCH 11/16] working_directory again --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c5a6ec938..3da7460ac3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,6 +67,7 @@ jobs: root: . paths: - 'dist' + working_directory: /app deploy: docker: From aaeb9f16ed6abd1ae35ef6466e1e3738557b7b64 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 14:21:55 -0500 Subject: [PATCH 12/16] Try deploying to fallback S3 bucket --- .circleci/config.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3da7460ac3..aef8b3fcd0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,6 +61,7 @@ jobs: password: $DOCKER_PASS environment: GIT_REVISION: $CIRCLE_SHA1 + NODE_ENV: production steps: - run: yarn run gulp build - persist_to_workspace: @@ -71,11 +72,13 @@ jobs: deploy: docker: - - image: popcodeorg/popcode:$CIRCLE_BRANCH - auth: - username: $DOCKER_USER - password: $DOCKER_PASS + - image: ubuntu:latest steps: - attach_workspace: at: . - - run: ls -l dist + - aws-s3/sync: + from: dist + to: 's3://popcode.school/' + arguments: | + --acl public-read + overwrite: true From 5818742e8bb079920604b509f74da1b35aed1cb1 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 14:24:02 -0500 Subject: [PATCH 13/16] Remove overwrite key --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aef8b3fcd0..fddb79e541 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -81,4 +81,3 @@ jobs: to: 's3://popcode.school/' arguments: | --acl public-read - overwrite: true From 1490fb96325260c7c14850faaf75a6d559f8c058 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 14:30:46 -0500 Subject: [PATCH 14/16] Pretend commit From 86842d612cd1e9895e38efef566251707652be27 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 14:51:42 -0500 Subject: [PATCH 15/16] Use base Circle convenience image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fddb79e541..4857dc8b31 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,7 +72,7 @@ jobs: deploy: docker: - - image: ubuntu:latest + - image: cimg/base:latest steps: - attach_workspace: at: . From 206c1662b0cd400f34043b79f7e8b18ccc315278 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sat, 6 Mar 2021 15:07:25 -0500 Subject: [PATCH 16/16] Stable tag --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4857dc8b31..7bf05f644d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,7 +72,7 @@ jobs: deploy: docker: - - image: cimg/base:latest + - image: cimg/base:stable steps: - attach_workspace: at: .