Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- references:
- commands:
- setup_heroku: &setup_heroku
- name: Setup Heroku
- command: bash .circleci/setup-heroku.sh
- deploy_heroku: &deploy_heroku
- name: Deploy Heroku
- command: |
- git push -f git@heroku.com:$HEROKU_APP_NAME.git master
- heroku run rake db:migrate -a $HEROKU_APP_NAME
- sleep 5 # sleep for 5 seconds to wait for dynos
- heroku restart -a $HEROKU_APP_NAME
- version: 2
- jobs:
- build:
- parallelism: 1
- docker:
- - image: circleci/ruby:2.5.0-node-browsers
- environment:
- BUNDLE_JOBS: 3
- BUNDLE_RETRY: 3
- BUNDLE_PATH: vendor/bundle
- REDIS_HOST: 127.0.0.1
- PGHOST: 127.0.0.1
- PGUSER: postgres
- RAILS_ENV: test
- - image: circleci/postgres:9.4.16-alpine-postgis
- environment:
- POSTGRES_USER: postgres
- POSTGRES_DB: tsukulink_test
- POSTGRES_PASSWORD: xxxxxxxx
- - image: redis:4.0.8-alpine
- steps:
- - checkout
- # Which version of bundler?
- - run:
- name: Which bundler?
- command: bundle -v
- # Restore bundle cache
- - restore_cache:
- keys:
- - rails-tsukulink-bundle-v2-{{ checksum "Gemfile.lock" }}
- - rails-tsukulink-bundle-v2-
- - run:
- name: Bundle Install
- command: bundle check || bundle install
- # Store bundle cache
- - save_cache:
- key: rails-tsukulink-bundle-v2-{{ checksum "Gemfile.lock" }}
- paths:
- - vendor/bundle
- # # Only necessary if app uses webpacker or yarn in some other way
- # - restore_cache:
- # keys:
- # - rails-tsukulink-yarn-{{ checksum "yarn.lock" }}
- # - rails-tsukulink-yarn-
- #
- # - run:
- # name: Yarn Install
- # command: yarn install --cache-folder ~/.cache/yarn
- #
- # # Store yarn / webpacker cache
- # - save_cache:
- # key: rails-tsukulink-yarn-{{ checksum "yarn.lock" }}
- # paths:
- # - ~/.cache/yarn
- - run:
- name: Wait for DB
- command: dockerize -wait tcp://localhost:5432 -timeout 1m
- - run:
- name: Database setup
- command: bin/rails db:schema:load --trace
- # Run rspec in parallel
- - type: shell
- command: |
- bundle exec rspec --profile 10 \
- --format RspecJunitFormatter \
- --out test_results/rspec.xml \
- --format progress \
- $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
- # Save test results for timing analysis
- - store_test_results:
- path: test_results
- deploy_staging:
- machine:
- enabled: true
- environment:
- HEROKU_APP_NAME: tsukulink-staging
- steps:
- - checkout
- - add_ssh_keys:
- fingerprints:
- - "xxxxx"
- - run: *setup_heroku
- - run: *deploy_heroku
- deploy_release:
- machine:
- enabled: true
- environment:
- HEROKU_APP_NAME: tsukulink
- steps:
- - checkout
- - add_ssh_keys:
- fingerprints:
- - "xxxxx"
- - run: *setup_heroku
- - run: *deploy_heroku
- workflows:
- version: 2
- build-and-deploy:
- jobs:
- - build
- - deploy_staging:
- requires:
- - build
- filters:
- branches:
- only: master
- - deploy_release:
- requires:
- - build
- filters:
- branches:
- only: release
Add Comment
Please, Sign In to add comment