include: ci-templates/core.yml

workflow:
  rules:
    - if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_NAME =~ /^kinetic-.*/
      variables:
        DEFAULT_DISTRO: "kinetic"
    - if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_NAME =~ /^melodic-.*/
      variables:
        DEFAULT_DISTRO: "melodic"
    - if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_NAME =~ /^noetic-.*/
      variables:
        DEFAULT_DISTRO: "noetic"
    - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^kinetic-.*/
      variables:
        DEFAULT_DISTRO: "kinetic"
        DEPLOY: "true"
    - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^melodic-.*/
      variables:
        DEFAULT_DISTRO: "melodic"
        DEPLOY: "true"
    - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^noetic-.*/
      variables:
        DEFAULT_DISTRO: "noetic"
        DEPLOY: "true"
    - if: $CI_COMMIT_TAG
      variables:
        DEPLOY: "true"
    - if: $CI_COMMIT_BRANCH


industrial_ci_kinetic:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: kinetic
  rules:
    - if: $DEPLOY
      when: never
    - if: $DEFAULT_DISTRO == "kinetic"
    - if: $BUILD_KINETIC

industrial_ci_melodic:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: melodic
  rules:
    - if: $DEPLOY
      when: never
    - if: $DEFAULT_DISTRO == "melodic"
    - if: $BUILD_MELODIC

industrial_ci_noetic:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: noetic
  rules:
    - if: $DEPLOY
      when: never
    - if: $DEFAULT_DISTRO == "noetic"
    - if: $BUILD_NOETIC


industrial_kinetic_deploy:
  extends:
    - industrial_ci_kinetic
    - .industrial_ci_deploy
  rules:
    - if: $DEPLOY && $DEFAULT_DISTRO == "kinetic"
    - if: $DEPLOY && $BUILD_KINETIC

industrial_melodic_deploy:
  extends:
    - industrial_ci_melodic
    - .industrial_ci_deploy
  rules:
    - if: $DEPLOY && $DEFAULT_DISTRO == "melodic"
    - if: $DEPLOY && $BUILD_MELODIC

industrial_noetic_deploy:
  extends:
    - industrial_ci_noetic
    - .industrial_ci_deploy
  rules:
    - if: $DEPLOY && $DEFAULT_DISTRO == "noetic"
    - if: $DEPLOY && $BUILD_NOETIC
