# This is an example Starter pipeline configuration
# Use a skeleton to build, test and deploy using manual and parallel steps
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.2-fpm

pipelines:
  branches:
    # testing pipeline
    feature/*:
      - step:
          name: 'Start FTP to test-api.cleaning-manager.eu on feature commit'
          script:
            - apt-get update
            - apt-get -qq install git-ftp
            - git config git-ftp.url $FTP_DOMAIN
            - git config git-ftp.user $TEST_FTP_USERNAME
            - git config git-ftp.password $TEST_FTP_PASSWORD
#           init only at first run
            # - git ftp init -vv
#           Everything else
            - git ftp push -vv
#           Clear cache
            - curl https://test-api.cleaning-manager.eu/api/technical/clear_cache

    # production pipeline
    develop:
      - step:
          name: 'Start FTP to platon-api.cleaning-manager.eu on develop commit'
          script:
            - apt-get update
            - apt-get -qq install git-ftp
            - git config git-ftp.url $FTP_DOMAIN
            - git config git-ftp.user $FTP_USERNAME
            - git config git-ftp.password $FTP_PASSWORD
#           init only at first run
            # - git ftp init -vv
#           Everything else
            - git ftp push -vv
#           Clear cache
            - curl https://platon-api.cleaning-manager.eu/api/technical/clear_cache

      - step:
          name: 'Start FTP to demo-api.cleaning-manager.eu on develop commit'
          script:
            - apt-get update
            - apt-get -qq install git-ftp
            - git config git-ftp.url $FTP_DOMAIN
            - git config git-ftp.user $DEMO_FTP_USERNAME
            - git config git-ftp.password $DEMO_FTP_PASSWORD
#           init only at first run
            # - git ftp init -vv
#           Everything else
            - git ftp push -vv
#           Clear cache
            - curl https://demo-api.cleaning-manager.eu/api/technical/clear_cache

      - step:
          name: 'Start FTP to trial-api.cleaning-manager.eu on develop commit'
          script:
            - apt-get update
            - apt-get -qq install git-ftp
            - git config git-ftp.url $FTP_DOMAIN
            - git config git-ftp.user $TRIAL_FTP_USERNAME
            - git config git-ftp.password $TRIAL_FTP_PASSWORD
#           init only at first run
            # - git ftp init -vv
          # Everything else
            - git ftp push -vv
#           Clear cache
            - curl https://trial-api.cleaning-manager.eu/api/technical/clear_cache
