workflow:
  rules:
    # Аварийный рубильник: «Run pipeline» c переменной RUN_ALL=true прогоняет
    # все gradle-сервисы (кроме pcp-tgu-ui-service) независимо от изменений.
    - if: '$RUN_ALL == "true"'
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - services/pcp-ballistics-service/**/*
        - services/pcp-srpring-boot-admin-server/**/*
        - services/spring-cloud-config-server/**/*
        - services/pcp-complex-mission-service/**/*
        - services/tle-monitoring-service/**/*
        - services/pcp-mission-planing-service/**/*
        - services/pcp-request-service/**/*
        - services/pcp-stations-service/**/*
        - services/pcp-satellite-catalog-service/**/*
        - services/slots-service/**/*
        - services/pcp-ui-service/**/*
        - services/pcp-coverage-scheme-service/**/*
        - services/pcp-tgu-service/**/*
        - services/pcp-tgu-ui-service/**/*
        - services/pcp-dynamic-plan-service/**/*
        - services/pcp-gateway-service/**/*
        - libs/pcp-types-lib/**/*
        - libs/ballistics-lib/**/*
        - build.gradle.kts
        - settings.gradle.kts
        - gradle.properties
        - gradle/**/*
        - .gitlab-ci.yml
        - .gitlab/ci/**/*
        - helm/pcp-ballistics-service/**/*
        - helm/pcp-spring-boot-admin-server/**/*
        - helm/spring-cloud-config-server/**/*
        - helm/pcp-complex-mission-service/**/*
        - helm/tle-monitoring-service/**/*
        - helm/pcp-mission-planing-service/**/*
        - helm/pcp-request-service/**/*
        - helm/pcp-stations-service/**/*
        - helm/pcp-satellite-catalog-service/**/*
        - helm/slots-service/**/*
        - helm/pcp-ui-service/**/*
        - helm/pcp-coverage-scheme-service/**/*
        - helm/pcp-tgu-service/**/*
        - helm/pcp-tgu-ui-service/**/*
        - helm/pcp-dynamic-plan-service/**/*
        - helm/pcp-gateway-service/**/*
    - if: '$CI_PIPELINE_SOURCE == "push"'
      changes:
        - .gitlab-ci.yml
        - .gitlab/ci/**/*
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "dev"'
      changes:
        - services/pcp-ballistics-service/**/*
        - services/pcp-srpring-boot-admin-server/**/*
        - services/spring-cloud-config-server/**/*
        - services/pcp-complex-mission-service/**/*
        - services/tle-monitoring-service/**/*
        - services/pcp-mission-planing-service/**/*
        - services/pcp-request-service/**/*
        - services/pcp-stations-service/**/*
        - services/pcp-satellite-catalog-service/**/*
        - services/slots-service/**/*
        - services/pcp-ui-service/**/*
        - services/pcp-coverage-scheme-service/**/*
        - services/pcp-tgu-service/**/*
        - services/pcp-tgu-ui-service/**/*
        - services/pcp-dynamic-plan-service/**/*
        - services/pcp-gateway-service/**/*
        - libs/pcp-types-lib/**/*
        - libs/ballistics-lib/**/*
        - build.gradle.kts
        - settings.gradle.kts
        - gradle.properties
        - gradle/**/*
        - .gitlab-ci.yml
        - .gitlab/ci/**/*
        - helm/pcp-ballistics-service/**/*
        - helm/pcp-spring-boot-admin-server/**/*
        - helm/spring-cloud-config-server/**/*
        - helm/pcp-complex-mission-service/**/*
        - helm/tle-monitoring-service/**/*
        - helm/pcp-mission-planing-service/**/*
        - helm/pcp-request-service/**/*
        - helm/pcp-stations-service/**/*
        - helm/pcp-satellite-catalog-service/**/*
        - helm/slots-service/**/*
        - helm/pcp-ui-service/**/*
        - helm/pcp-coverage-scheme-service/**/*
        - helm/pcp-tgu-service/**/*
        - helm/pcp-tgu-ui-service/**/*
        - helm/pcp-dynamic-plan-service/**/*
        - helm/pcp-gateway-service/**/*
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"'
      changes:
        - services/pcp-ballistics-service/**/*
        - services/pcp-srpring-boot-admin-server/**/*
        - services/spring-cloud-config-server/**/*
        - services/pcp-complex-mission-service/**/*
        - services/tle-monitoring-service/**/*
        - services/pcp-mission-planing-service/**/*
        - services/pcp-request-service/**/*
        - services/pcp-stations-service/**/*
        - services/pcp-satellite-catalog-service/**/*
        - services/slots-service/**/*
        - services/pcp-ui-service/**/*
        - services/pcp-coverage-scheme-service/**/*
        - services/pcp-tgu-service/**/*
        - services/pcp-tgu-ui-service/**/*
        - services/pcp-dynamic-plan-service/**/*
        - services/pcp-gateway-service/**/*
        - libs/pcp-types-lib/**/*
        - libs/ballistics-lib/**/*
        - build.gradle.kts
        - settings.gradle.kts
        - gradle.properties
        - gradle/**/*
        - .gitlab-ci.yml
        - .gitlab/ci/**/*
        - helm/pcp-ballistics-service/**/*
        - helm/pcp-spring-boot-admin-server/**/*
        - helm/spring-cloud-config-server/**/*
        - helm/pcp-complex-mission-service/**/*
        - helm/tle-monitoring-service/**/*
        - helm/pcp-mission-planing-service/**/*
        - helm/pcp-request-service/**/*
        - helm/pcp-stations-service/**/*
        - helm/pcp-satellite-catalog-service/**/*
        - helm/slots-service/**/*
        - helm/pcp-ui-service/**/*
        - helm/pcp-coverage-scheme-service/**/*
        - helm/pcp-tgu-service/**/*
        - helm/pcp-tgu-ui-service/**/*
        - helm/pcp-dynamic-plan-service/**/*
        - helm/pcp-gateway-service/**/*
    - when: never

default:
  tags:
    - nstart

variables:
  INTERNAL_REGISTRY: "$CI_REGISTRY_IMAGE"

stages:
  - test
  - build
  - package
  - deploy

ci:config:
  stage: test
  image: alpine:3.20
  rules:
    - changes:
        - .gitlab-ci.yml
        - .gitlab/ci/**/*
    - when: never
  script:
    - echo "GitLab CI configuration changed"

include:
  - local: .gitlab/ci/pcp-ballistics-service.yml
  - local: .gitlab/ci/pcp-spring-boot-admin-server.yml
  - local: .gitlab/ci/spring-cloud-config-server.yml
  - local: .gitlab/ci/pcp-complex-mission-service-tle.yml
  - local: .gitlab/ci/pcp-mission-planing-service.yml
  - local: .gitlab/ci/pcp-request-service.yml
  - local: .gitlab/ci/pcp-stations-service.yml
  - local: .gitlab/ci/pcp-satellite-catalog-service.yml
  - local: .gitlab/ci/slots-service.yml
  - local: .gitlab/ci/pcp-ui-service.yml
  - local: .gitlab/ci/pcp-coverage-scheme-service.yml
  - local: .gitlab/ci/pcp-tgu-service.yml
  - local: .gitlab/ci/pcp-tgu-ui-service.yml
  - local: .gitlab/ci/pcp-dynamic-plan-service.yml
  - local: .gitlab/ci/pcp-gateway-service.yml
