version: 2.1

orbs:
  ruby-orbs: sue445/ruby-orbs@volatile
  heroku:    circleci/heroku@volatile
  slack:     circleci/slack@volatile

executors:
  default:
    docker:
      - image: circleci/ruby:2.7.2
        environment:
          RACK_ENV: test
      - image: circleci/postgres:9.4-alpine-ram
        environment:
          POSTGRES_USER: ubuntu
          POSTGRES_DB: circle_test
    working_directory: ~/app

jobs:
  rspec:
    executor:
      name: default

    steps:
      - checkout
      - ruby-orbs/bundle-install:
          cache_key_prefix: "v3-bundle"
      - run: cp .circleci/database.yml config/database.yml
      - run: bundle exec rake ar:migrate:reset
      - run: bundle exec rspec
      - slack/notify:
          event: fail
          template: basic_fail_1
          
  rubocop:
    executor:
      name: default

    steps:
      - checkout
      - ruby-orbs/bundle-install:
          cache_key_prefix: "v3-bundle"
      - run: bundle exec rubocop
      - slack/notify:
          event: fail
          template: basic_fail_1
          
workflows:
  version: 2

  build-and-deploy:
    jobs:
      - rspec
      - rubocop
      - heroku/deploy-via-git:
          context: Heroku
          requires:
            - rspec
            - rubocop
          filters:
            branches:
              only: master
          post-deploy:
            - slack/status

version: 2.1

orbs:
  ruby-orbs: sue445/ruby-orbs@volatile
  heroku:    circleci/heroku@volatile
  slack:     circleci/slack@volatile

executors:
  default:
    docker:
      - image: circleci/ruby:2.7.2
        environment:
          RACK_ENV: test
      - image: circleci/postgres:9.4-alpine-ram
        environment:
          POSTGRES_USER: ubuntu
          POSTGRES_DB: circle_test
    working_directory: ~/app

jobs:
  rspec:
    executor:
      name: default

    steps:
      - checkout
      - ruby-orbs/bundle-install:
          cache_key_prefix: "v3-bundle"
      - run: cp .circleci/database.yml config/database.yml
      - run: bundle exec rake ar:migrate:reset
      - run: bundle exec rspec
      - slack/status

  rubocop:
    executor:
      name: default

    steps:
      - checkout
      - ruby-orbs/bundle-install:
          cache_key_prefix: "v3-bundle"
      - run: bundle exec rubocop
      - slack/status

workflows:
  version: 2

  build-and-deploy:
    jobs:
      - rspec
      - rubocop
      - heroku/deploy-via-git:
          context: Heroku
          requires:
            - rspec
            - rubocop
          filters:
            branches:
              only: master
          post-deploy:
            - slack/status

Revert "slack/status is removed since circleci/slack v4.0.0"
Revert "slack/status is removed since circleci/slack v4.0.0"

This reverts commit 54f0b02b093545837844d54f4ac21e13ddd9bf3f.
