Detecting for branch and running commands on specific branches


#1

Hello, everyone. I have circleci running on git when new code is pushed and merged. I also have laravel envoyer to run deployment for me, however in order for it to run I need to ping an url it gives me. I.e http://envoy/deploy etc. However there is a different link for develop and production server. Now here’s the question. Is it possible to detect which git branch is being tested? I.e. if branch = develop do something. If master do something else?

version: 2

jobs:
build:
working_directory: ~/liveandnow

environment:
  BASH_ENV: ~/.bashrc

docker:
  - image: circleci/php:latest
  - image: circleci/mysql:latest
steps:

  - run:
      name: Install System Dependencies
      command: |
        sudo apt-get update
        sudo apt-get install -y libmcrypt-dev git unzip wget libpng-dev libsqlite3-dev
        # These are required for e2e tests
        sudo apt-get install -y libsqlite3-dev libnss3 libgconf-2-4 libfontconfig1 chromium xvfb

  - run:
      name: Install PhP Extensions
      command: |
        sudo docker-php-ext-install mysqli pdo pdo_mysql

  - checkout

  - run:
      name: Get Node
      command: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

  - run:
      name: Install Node
      command: sudo apt-get install -y nodejs

  - run:
      name: Update Composer
      command: sudo composer self-update

  - run:
      name: Install Composer Dependencies
      command: composer install --no-progress --no-suggest


  - run:
      name: Adjust Permissions
      command: |
        sudo chmod -R 777 storage
        sudo chmod -R 777 bootstrap

  - run:
      name: Versions
      command: |
        node --version
        npm --version
        php --version

  - run:
      name: Install Node Dependencies
      command: npm install

  - run:
      name: Webpack
      command: npm run prod

  - run:
      name: Migrate
      command: php artisan migrate  --force

  - run:
      name: Start xvfb
      background: true
      command: /usr/bin/Xvfb :0 -screen 0 1280x720x24

  - run:
      name: Open Browsers
      background: true
      command: DISPLAY=:0 ./vendor/laravel/dusk/bin/chromedriver-linux

  - run:
      name: Serve Application
      background: true
      command: php artisan serve

  - run:
      name: Dusk Tests
      command: php artisan dusk

  - store_artifacts:
      path: ./tests/Browser/console
      destination: console

  - store_artifacts:
      path: ./tests/Browser/screenshots
      destination: screenshots

  - store_artifacts:
      path: ./storage/logs
      destination: logs

My other question is: can you split this config into multiple ones? So at the moment it runs this as one test however I would like it to be several tests and run them in the order as it is in this config.yaml. ideally I want 1 file for setting up a testing machine, 1 for installing packages, And another one for tests


#2