# Generated by `sfdt ci init --provider bitbucket --type release`.
# Merge this `branches` pipeline into your bitbucket-pipelines.yml. Deploys the
# changed-metadata delta since the last release tag to {{org}} on every push to
# {{branch}} — a real deploy, not a validation. The step is bound to the
# {{environment}} deployment environment; restricting who may deploy to it
# (deployment permissions) requires Bitbucket Premium. On other plans, prefer
# the commented `custom` variant at the bottom and trigger the deploy manually.
#
# 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 repository variables (Repository settings > Pipelines > Variables, secured):
{{authSecretsDoc}}
#   SLACK_WEBHOOK_URL    (optional) Slack incoming webhook for deploy notifications
#   TEAMS_WEBHOOK_URL    (optional) Microsoft Teams incoming webhook
pipelines:
  branches:
    '{{branch}}':
      - step:
          name: SFDT Release Deploy
          image: {{image}}
          deployment: {{environment}}
          clone:
            depth: full
          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
# Manual-trigger alternative (works on all plans): move the step above under
#   custom:
#     sfdt-release:
# and run it from Pipelines > Run pipeline when ready to release.
