stages:
  - build
  - start
  - stop
  - uninstall
  - remove

build-faircoind:
  stage: build
  tags:
    - FairCoin.Co
  only:
    refs:
      - master
    variables:
      - $CMD =~ /build/
  before_script:
    - mkdir -p ~/.faircoin2
    - cp ${FAIRCOIN_CONF} ~/.faircoin2/faircoin.conf
#    - source ${FAIRCOIN_CONF}
#    - echo -e "rpcconnect=${rpcconnect}\nrpcport=${rpcport}\nrpcuser=${rpcuser}\nrpcpassword=${rpcpassword}\ntxindex=1" > ~/.faircoin2/faircoin.conf
  script:
    - docker-compose down
    - docker-compose build

start-faircoind:
  stage: start
  tags:
    - FairCoin.Co
  only:
    refs:
      - master
    variables:
      - $CMD =~ /build|start/
  script:
    - docker-compose down
    - docker-compose up -d

stop-faircoind:
  stage: stop
  tags:
    - FairCoin.Co
  only:
    refs:
      - master
    variables:
      - $CMD =~ /stop/
  script:
    - docker-compose stop

uninstall-faircoind:
  stage: uninstall
  tags:
    - FairCoin.Co
  only:
    refs:
      - master
    variables:
      - $CMD =~ /uninstall/
  script:
    - docker-compose down

remove-faircoind:
  stage: remove
  tags:
    - FairCoin.Co
  only:
    refs:
      - master
    variables:
      - $CMD =~ /remove/
  script:
    - docker-compose down
  after_script:
    - echo ${CI_PROJECT_DIR} > ~/test.txt
    - rm -R ~/.faircoin2
