---
kind: pipeline
type: ssh
name: Carhop | Plugins | Déploiment des Plugins

clone:
        disable: true

server:
        host:
                from_secret: build_server_host
        user:
                from_secret: build_server_user
        password:
                from_secret: build_server_password

steps:
        - name: Clonage du Repo
          commands:
                  - git clone https://git.deligraph.be/Antoine/carhop__plugins__PROD-DEV.git
        - name: Déploiement des mu-plugins
          environment:
                  DEV_SERVER_PATH:
                          from_secret: dev_server_path
                  PROD_SERVER_PATH:
                          from_secret: prod_server_path

          commands:
                  - cd carhop__plugins__PROD-DEV
                  - rsync -avhp -e 'ssh -p 1982' ./mu-plugins/ $DEV_SERVER_PATH:~/carhop/wordpress/wp-content/mu-plugins --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh' ./mu-plugins/ $PROD_SERVER_PATH:~/sites/carhop.be/wp-content/mu-plugins --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'

        - name: Déploiement des plugins
          environment:
                  DEV_SERVER_PATH:
                          from_secret: dev_server_path
                  PROD_SERVER_PATH:
                          from_secret: prod_server_path
          commands:
                  - cd carhop__plugins__PROD-DEV
                  - echo "DÉPLOIEMENT SUR LE SERVEUR DEV"
                  - rsync -avhp -e 'ssh -p 1982' ./plugins/carhop-blocks/ $DEV_SERVER_PATH:~/carhop/wordpress/wp-content/plugins/carhop-blocks --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh -p 1982' ./plugins/dynamiques-blocks/ $DEV_SERVER_PATH:~/carhop/wordpress/wp-content/plugins/dynamiques-blocks --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh -p 1982' ./plugins/carhop-format-types/ $DEV_SERVER_PATH:~/carhop/wordpress/wp-content/plugins/carhop-format-types --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh -p 1982' ./plugins/dynamiques-modification-date/ $DEV_SERVER_PATH:~/carhop/wordpress/wp-content/plugins/dynamiques-modification-date --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - echo "DÉPLOIEMENT SUR LE SERVEUR PROD"
                  - rsync -avhp -e 'ssh' ./plugins/carhop-blocks/ $PROD_SERVER_PATH:~/sites/carhop.be/wp-content/plugins/carhop-blocks --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh' ./plugins/dynamiques-blocks/ $PROD_SERVER_PATH:~/sites/carhop.be/wp-content/plugins/dynamiques-blocks --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh' ./plugins/carhop-format-types/ $PROD_SERVER_PATH:~/sites/carhop.be/wp-content/plugins/carhop-format-types --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
                  - rsync -avhp -e 'ssh' ./plugins/dynamiques-modification-date/ $PROD_SERVER_PATH:~/sites/carhop.be/wp-content/plugins/dynamiques-modification-date --delete --exclude 'node_modules' --exclude 'Makefile' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev'
