default:
  image: node:12

before_script:
  - npm ci

stages:
  - source_check
  - build
  - test
  - deploy

check_format:
  stage: source_check
  script:
    - npx prettier --ignore-path .gitignore --check "**/*.{html,js,json,md}"

lint:
  stage: source_check
  script:
    - npx eslint --ignore-path .gitignore "**/*.js"

backend_build:
  stage: build
  script:
    - npm run build
  artifacts:
    paths:
      - .

backend_test:
  stage: test
  script:
    - npm test

deploy:
  stage: deploy
  script:
    - apt-get update -qq && apt-get install -qq zip
    - zip -r application.zip * .[^.]*
    - curl -X POST -u "$DEPLOYMENT_USERNAME:$DEPLOYMENT_PASSWORD" $DEPLOYMENT_ENDPOINT -T application.zip