.maven_build:
  extends: .default
  stage: build
  image: maven:3.9.9-ibm-semeru-17-focal
  script:
    - mvn deploy -s ci_settings.xml -Dversion=$APP_VERSION
  artifacts:
    paths:
      - target/

.docker_build:
  extends: .default
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - export DOCKER_TAG=$APP_VERSION
    - |
      if [ "$CI_COMMIT_REF_NAME" = "main" ]; then
        echo "Pushing Docker image with tag 'latest'"
        export DOCKER_TAG=latest
      fi
    - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:$DOCKER_TAG"

.angular_build:
  extends: .default
  stage: build
  image: trion/ng-cli:14.2.9
  script:
    - |
      if [ ! -f  "./src/assets/config/theming.scss" ]; then
          cp ./src/assets/config/theming.default.scss ./src/assets/config/theming.scss
      fi
      if [ ! -f  "./src/assets/config/config.prod.json" ]; then
          cp ./src/assets/config/config.prod.default.json ./src/assets/config/config.prod.json
      fi
    - npm install
    - ng build --configuration production
  artifacts:
    paths:
      - dist/
