variables:
  LOCAL_DIR: public

stages: 
 - build
 - production_deployment


brunch_build:
  stage: build
  image: node
  script:
    - npm i
    - npm run-script build
  artifacts:
    paths:
      - public/*
    expire_in: 3 days


production_deploy: 
  stage: production_deployment
  dependencies:
    - brunch_build
  variables:
    NAMESPACE: tls-tracking

  when: manual
  image: alpine/k8s:1.28.2
  script:
  - kubectl config use-context frank/tls-tracking:cumulus-agent
  - kubectl config set-context --current --namespace $NAMESPACE
  - kubectl apply -f "$AWS_ROUTE53_CREDS"
  - kubectl apply -f kubernetes.yaml
  - kubectl wait --for=condition=ready pod -l app=tls-tracking-webserver
  - kubectl cp public $(kubectl get pod -l app=tls-tracking-webserver -o name | cut -d '/' -f2):/var/www/

  environment:
    name: Production
    url: http://tls-tracking.sauerburger.com/

