cache:
  paths:
    - vendor/
    - node_modules/
    - .env

before_script:
  - cp .env.example .env

building:
  stage: build
  except:
    - schedules
  script:
    - composer install
    - npm install
    - npm run build

testing:
  stage: test
  except:
    - schedules
  script:
    - composer install
    - npm install
    - npm run build
    - php artisan key:generate
    - php artisan config:cache
    - php artisan migrate:fresh
    - ./vendor/bin/phpunit tests

deploy_dev:
  stage: deploy
  except:
    - schedules
  environment:
    name: O2SWITCH - daerian.net
    url: "$DEV_URL"
  only:
    - main
    - dev
  script:
    - ssh "$DEV_SSH_USERNAME"@"$DEV_SSH_HOST" -p "$DEV_SSH_PORT" "cd $DEV_URL && git stash && git pull origin dev && composer install && npm install && php artisan migrate --force && php artisan cache:clear && php artisan config:cache && php artisan view:cache && php artisan route:cache && php artisan event:cache && composer install --optimize-autoloader --no-dev && npm run build"
