version: 2

jobs:
  single_build:
    docker:
      - image: obono/arduboy-env:2.0
    working_directory: /home/circleci/working
    steps:
      - checkout
      - run:
          name: Build
          command: .circleci/build.sh ${CIRCLE_BRANCH%_dev}
  build_and_deploy:
    docker:
      - image: obono/arduboy-env
    working_directory: /home/circleci/working
    steps:
      - checkout
      - run:
          name: Build
          command: .circleci/build.sh all
      - run:
          name: Update information
          command: .circleci/jq_repo.sh | tee docs/repo.json | mustache .circleci/README.md.mustache > README.md
      - run:
          name: Push to GitHub
          command: .circleci/git_push.sh

workflows:
  version: 2
  workflow:
    jobs:
      - single_build:
          filters:
            branches:
              only: /.*_dev/
      - build_and_deploy:
          filters:
            branches:
              only: master
