# Generated by `sfdt ci init --provider gitlab --type release`.
# Merge this job into your .gitlab-ci.yml. Deploys the changed-metadata delta
# since the last release tag to {{org}} when {{branch}} is updated — a real
# deploy, not a validation. The job is manual (play button) and bound to the
# {{environment}} environment: protect it (Settings > CI/CD > Protected
# environments) to restrict who can trigger the deploy.
#
# Delta base: the most recent tag (git describe). Tag each release — for example
# with `sfdt release <version>` — to keep deltas exact; with no tag in history
# the delta falls back to {{deltaBase}}, which can miss earlier commits of a
# multi-commit merge.
#
# --notify pushes the deploy outcome through the channels configured under
# `notifications` in .sfdt/config.json (secrets referenced by env-var name).
#
# Required CI/CD variables (Settings > CI/CD > Variables, masked):
{{authSecretsDoc}}
#   SLACK_WEBHOOK_URL    (optional) Slack incoming webhook for deploy notifications
#   TEAMS_WEBHOOK_URL    (optional) Microsoft Teams incoming webhook
sfdt-release:
  image: {{image}}
  rules:
    - if: '$CI_COMMIT_BRANCH == "{{branch}}"'
      when: manual
  variables:
    GIT_DEPTH: 0
  environment:
    name: {{environment}}
  script:
    {{cliSetup}}
    {{authSteps}}
    - BASE=$(git describe --tags --abbrev=0 2>/dev/null || echo "{{deltaBase}}")
    - echo "Deploying delta since $BASE"
    - {{cli}} deploy --smart --org {{org}} --delta-base "$BASE" --notify
