# This is a basic workflow to help you get started with Actions

name: CI-CD develop

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "master" branch
  push:
    branches: [ "develop" ]
  pull_request:
    branches: [ "develop" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:


jobs:
  deploy:
    name: build dependencies & create artifact
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2.0.0
      - name: Check folders
        run: |
          cd ./src/
          ls -al
      - name: Install dependencies
        uses: php-actions/composer@v6
        with:
          dev: no
          args: --no-interaction --optimize-autoloader --ignore-platform-reqs
          php_version: "8.1"
          version: "2.2"
          working_dir: "src/"
      - name: Deploy to my server
        uses: up9cloud/action-rsync@master
        env:
          HOST: ssh.cluster023.hosting.ovh.net
          #KEY: ${{secrets.MB_RS_LABS_PUBLIC_KEY}}
          PASSWORD: ${{secrets.OVH_HOSTING_PASSWORD}} # it's less secure, using KEY instead
          TARGET: ./
          VERBOSE: true
          USER: ${{ secrets.OVH_HOSTING_USER }}
          # PORT: 2222 # no need to set this, because of $SSH_ARGS
          ARGS: -az
          SSH_ARGS: '-p 22 -o StrictHostKeyChecking=no'
          SOURCE: ./
          PRE_SCRIPT: |
            echo start at:
            date -u
          POST_SCRIPT: "echo done at: && date -u"


#      - name: rsync deployments
#        uses: burnett01/rsync-deployments@6.0.0
#        with:
#          switches: -avzr --delete
#          #path: src/
#          remote_path: ./
#          remote_host: ssh.cluster023.hosting.ovh.net
#          remote_user: ${{ secrets.OVH_HOSTING_USER }}
#          remote_key: ${{ secrets.MB_RS_LABS_PUBLIC_KEY }}

      # Optional step compiling JS files
#      - name: Build JS dependencies
#        uses: PrestaShopCorp/github-action-build-js/12@v1.0
#        with:
#          cmd: yarn
#          path: ./src/_dev

      # Install PHP dependencies (Production ONLY)
#      - name: Install composer dependencies
#        run: |
#          cd ./src/
#          composer install --no-dev -o

      # Remove development files
#      - name: Clean-up project
#        uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0

#      - name: Sync files
#        uses: SamKirkland/FTP-Deploy-Action@v4.3.4
#        with:
#          local-dir: ./src/
#          server-dir: ./
#          server: ftp.cluster023.hosting.ovh.net
#          username: ${{ secrets.OVH_HOSTING_USER }}
#          password: ${{ secrets.OVH_HOSTING_PASSWORD }}

#      # Zip files and upload to artifacts list
#      - name: Create & upload artifact
#        uses: actions/upload-artifact@v1
#        with:
#          name: ${{ github.event.repository.name }}
#          path: ../


