default:
  image: node:latest
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - node_modules/
      - .npm/

stages:          # List of stages for jobs, and their order of execution
  - build
  - deploy

build-job:       # This job runs in the build stage, which runs first.
  stage: build
  script:
    - npm install
    - npm run build
  artifacts:
    expire_in: 1 week
    paths:
    - ./build

deploy-job:      # This job runs in the deploy stage.
  dependencies:
    - build-job
  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
  script:
    - apt-get update -qq && apt-get install -y -qq lftp
    - lftp -c "open -u $USERNAME,$PASSWORD $HOST; mirror -Rnev ./build ./www --ignore-time --parallel=10 --exclude .htaccess --exclude-glob .git* --exclude .git/"
