stages:
  - build
  - deploy

build:
  image: ubuntu
  tags:
    - build
  stage: build
  script:
    - apt update
    - apt install -y curl gnupg
    - curl -sL https://deb.nodesource.com/setup_12.x | bash -
    - apt update
    - apt install -y nodejs
    - rm ./package-lock.json
    - npm install 
    - ./node_modules/@angular/cli/bin/ng build  --prod --base-href=/ --configuration=$CI_COMMIT_REF_NAME
  artifacts:
    paths:
      - ./dist/

deploy_test:
  stage: deploy
  only:
    - test@hpc-team/strudelv2_spa
  tags: 
    - deploy_test
  script:
    - echo "deploying test"
    - ls -l
    - ./install.sh
  dependencies:
    - build

deploy_dev:
  stage: deploy
  only:
    - dev@hpc-team/strudelv2_spa
  tags: 
    - deploy_dev
  script:
    - echo "deploying dev"
    - ls -l
    - ./install.sh
    - cp ./nginx_snippets/* /etc/nginx/snippets
  dependencies:
    - build

deploy_prod:
  stage: deploy
  only:
    - prod@hpc-team/strudelv2_spa
  tags: 
    - deploy_prod
  script:
    - echo "deploying prod" 
    - ls -l
    - ./install.sh
    - cp ./nginx_snippets/* /etc/nginx/snippets
  dependencies:
    - build
