cache:
  paths:
    - build/web

stages:
  - build
  - push
  - deploy

build:
  stage: build
  image: cirrusci/flutter:latest
  script:
    - flutter clean
    - flutter build web --web-renderer html
  only:
    - test
    - dev

push:
  stage: push
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
    - docker build --pull -t registry.gitlab.com/didvan/didvan-app/api:latest .
    - docker push registry.gitlab.com/didvan/didvan-app/api:latest
  only:
    - test
    - dev

deploy-test:
  stage: deploy
  image: python:3.10.2
  variables:
    COLLECT_ERROR: 1
  script:
    - pip install fandogh_cli --upgrade
    - fandogh login --username=$FAN_USR --password=$FAN_PASS
    - fandogh service apply -f ./deployment/test.yaml -p SEC_NAME
  only:
    - test

deploy-dev:
  stage: deploy
  image: python:3.10.2
  variables:
    COLLECT_ERROR: 1
  script:
    - pip install fandogh_cli --upgrade
    - fandogh login --username=$FAN_USR --password=$FAN_PASS
    - fandogh service apply -f ./deployment/dev.yaml -p SEC_NAME
  only:
    - dev