Can I run the command conditionally depending on the environment?

rails
circle.yml

#1

Below is the the extract of my circle.yml file

dependencies:
  pre:
    - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
    - sudo dpkg -i google-chrome.deb
    - sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome
    - rm google-chrome.deb
    - bundle check --path=/home/ubuntu/.bundle || bundle install --path=/home/ubuntu/.bundle --jobs=4 --retry=3:
        pwd: backend/ruby
    - npm install -g bower:
        pwd: frontend
    - ruby ./with_retry.rb npm install -g elm@0.16:
        pwd: frontend
    - bower install:
        pwd: frontend
    - npm install:
        pwd: frontend
    - ruby ./with_retry.rb elm package install --yes:
        pwd: frontend
    - sysconfcpus -n 2 elm-make --yes:
        pwd: frontend
    - sysconfcpus -n 2 npm run build:
        pwd: frontend
deployment:
  production:
    branch: master
    commands:
      - bundle exec mina deploy TO=production:
          pwd: backend/ruby
      - bash ./deploy-frontend.sh:
          pwd: frontend
      - bundle exec mina restart_puma_inspection TO=production:
          pwd: backend/ruby
  staging:
    branch: staging
    commands:
      - bundle exec mina deploy TO=staging:
          pwd: backend/ruby
      - bash ./deploy-frontend-staging.sh:
          pwd: frontend
      - bundle exec mina passenger_restart TO=staging:
          pwd: backend/ruby

Based on deployment environment, I need to replace this command - sysconfcpus -n 2 npm run build: with - sysconfcpus -n 2 npm run stage: . Is this possible?


#2

Should be yes. You can use a Bash if block to test the environment, then run what you need.


#3