version: 2
jobs:
  build:
    working_directory: ~/package-tracker
    docker:
      - image: pawurb/ruby-jemalloc-node-yarn:latest
        environment:
          RAILS_ENV: test
      - image: circleci/postgres:9.4.12-alpine
    steps:
      - checkout

      # Restore bundle cache
      - type: cache-restore
        key: package-tracker-{{ checksum "Gemfile.lock" }}

      # Bundle install dependencies
      - run: bundle install --path vendor/bundle

      # Store bundle cache
      - type: cache-save
        key: package-tracker-{{ checksum "Gemfile.lock" }}
        paths:
          - vendor/bundle

      - type: shell
        command: bundle exec rubocop

      # Save artifacts
      - type: store_test_results
        path: /tmp/test-results


version: 2
jobs:
  test:
    working_directory: ~/package-tracker
    docker:
      - image: pawurb/ruby-jemalloc-node-yarn:latest
        environment:
          RAILS_ENV: test
      - image: circleci/postgres:9.4.12-alpine
    steps:
      - checkout

      # Restore bundle cache
      - type: cache-restore
        key: package-tracker-{{ checksum "Gemfile.lock" }}

      # Bundle install dependencies
      - run: bundle install --path vendor/bundle

      # Store bundle cache
      - type: cache-save
        key: package-tracker-{{ checksum "Gemfile.lock" }}
        paths:
          - vendor/bundle

      - type: shell
        command: bundle exec rubocop

      # Save artifacts
      - type: store_test_results
        path: /tmp/test-results
  deploy:
    steps:
      - add_ssh_keys:
        fingerprints:
          - "27:70:c5:09:00:c4:03:97:13:2e:f5:47:e4:a2:3f:97"
      - checkout
      - run:
        name: Deploy with git push
        command: |
          git push $GIT_DEPLOY_USERNAME@$GIT_DEPLOY_HOST:package-tracker master

workflows:
  version: 2
  test-and-deploy:
    jobs:
      - test
      - deploy:
        requires:
          - build
        filters:
          branches:
            only: master


Add deploy job to CircleCI
Add deploy job to CircleCI
