version: 2 production_env: &production_env environment: - SERVER_HOST=https://server-alpha.offen.dev - SCRIPT_HOST=https://script-alpha.offen.dev - AUDITORIUM_HOST=https://auditorium-alpha.offen.dev - VAULT_HOST=https://vault-alpha.offen.dev - HOMEPAGE_HOST=https://www.offen.dev - NODE_ENV=production - SECRET_ID_SERVER_CONNECTION_STRING=alpha/server/postgresConnectionString deploy_preconditions: &deploy_preconditions requires: - server - vault - script - auditorium - packages filters: branches: only: /^master$/ build_preconditions: &build_preconditions filters: branches: ignore: gh-pages jobs: server: docker: - image: circleci/golang:1.12 environment: - POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable - PORT=8080 - EVENT_RETENTION_PERIOD=4464h - image: circleci/postgres:11.2-alpine environment: - POSTGRES_USER=circle - POSTGRES_PASSWORD=test working_directory: ~/offen/server steps: - checkout: path: ~/offen - restore_cache: key: offen-server-{{ checksum "go.mod" }} - run: name: Download modules command: go mod download - save_cache: paths: - /go/pkg/mod key: offen-server-{{ checksum "go.mod" }} - run: name: Waiting for Postgres to be ready command: | for i in `seq 1 10`; do nc -z localhost 5432 && echo Success && exit 0 echo -n . sleep 1 done echo Failed waiting for Postgres && exit 1 - run: name: Run tests command: | cp ~/offen/bootstrap.yml . make test-ci vault: docker: - image: circleci/node:10-browsers working_directory: ~/offen/vault steps: - checkout: path: ~/offen - restore_cache: key: offen-vault-{{ checksum "package.json" }} - run: name: Install dependencies command: npm install - save_cache: paths: - ~/offen/vault/node_modules key: offen-vault-{{ checksum "package.json" }} - run: name: Run tests command: npm test script: docker: - image: circleci/node:10-browsers working_directory: ~/offen/script steps: - checkout: path: ~/offen - restore_cache: key: offen-script-{{ checksum "package.json" }} - run: name: Install lsof command: sudo apt-get install lsof - run: name: Install dependencies command: npm install - save_cache: paths: - ~/offen/script/node_modules key: offen-script-{{ checksum "package.json" }} - run: name: Run tests command: npm test auditorium: docker: - image: circleci/node:10-browsers working_directory: ~/offen/auditorium steps: - checkout: path: ~/offen - restore_cache: key: offen-auditorium-{{ checksum "package.json" }} - run: name: Install lsof command: sudo apt-get install lsof - run: name: Install dependencies command: npm install - save_cache: paths: - ~/offen/auditorium/node_modules key: offen-auditorium-{{ checksum "package.json" }} - run: name: Run tests command: npm test packages: docker: - image: circleci/node:10-browsers working_directory: ~/offen/packages steps: - checkout: path: ~/offen - restore_cache: key: offen-packages-{{ checksum "package.json" }} - run: name: Install lsof command: sudo apt-get install lsof - run: name: Install dependencies command: npm install - save_cache: paths: - ~/offen/packages/node_modules key: offen-packages-{{ checksum "package.json" }} - run: name: Run tests command: npm test deploy_homepage: docker: - image: circleci/python:3.6-node working_directory: ~/offen/homepage environment: - SOURCE_BRANCH: master - TARGET_BRANCH: gh-pages steps: - checkout: path: ~/offen - restore_cache: key: offen-homepage-{{ checksum "requirements.txt" }} - run: name: Install dependencies command: | python -m venv venv source venv/bin/activate pip install -r requirements.txt - save_cache: paths: - ~/offen/homepage/venv key: offen-homepage-{{ checksum "requirements.txt" }} - run: name: Install image optimization deps command: | sudo npm install svgo -g sudo apt-get install libjpeg-progs optipng - run: name: Deploy command: | source venv/bin/activate git config --global user.email $GH_EMAIL git config --global user.name $GH_NAME git clone $CIRCLE_REPOSITORY_URL out cd out git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH git rm -rf . cd .. make publish cp -a output/. out/. mkdir -p out/.circleci && cp -a ./../.circleci/. out/.circleci/. cp CNAME out/CNAME cd out git add -A git commit -m "Automated deployment to GitHub Pages: ${CIRCLE_SHA1}" --allow-empty git push origin $TARGET_BRANCH workflows: version: 2 test_build_deploy: jobs: - server: <<: *build_preconditions - vault: <<: *build_preconditions - script: <<: *build_preconditions - auditorium: <<: *build_preconditions - packages: <<: *build_preconditions - deploy_homepage: <<: *deploy_preconditions