stages:
  - .pre
  - build
  - test
  - post
  - security

# Default configuration for all jobs
.default:
  before_script:
    - |
      if [ "$CI_COMMIT_REF_NAME" = "main" ] && [ -n "$CI_COMMIT_TAG" ]; then
        export APP_VERSION=$CI_COMMIT_TAG
      elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then
        export APP_VERSION="develop"
      fi

# Configuration for jobs on protected branches
.default_protected:
  extends: .default
  rules:
    - if: $CI_COMMIT_REF_PROTECTED == "true"

# Configuration for jobs on unprotected branches
.default_unprotected:
  # extends: .default
  variables:
    APP_VERSION: $CI_COMMIT_REF_NAME
  rules:
    - if: $CI_COMMIT_REF_PROTECTED != "true"
  artifacts:
    expire_in: 1 day
