# Generated by `sfdt ci init --provider azure --type release`.
# A standalone Azure Pipelines definition for release deploys from {{branch}} —
# a real deploy, not a validation. Uses a deployment job bound to the
# '{{environment}}' Environment: create the Environment first (Pipelines >
# Environments) and add "Approvals and checks" to gate the deploy behind manual
# approval — plain script jobs do not honour Environment approvals.
#
# 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 pipeline variables (Pipelines > Library / pipeline variables, secret):
{{authSecretsDoc}}
#   SLACK_WEBHOOK_URL    (optional) Slack incoming webhook for deploy notifications
#   TEAMS_WEBHOOK_URL    (optional) Microsoft Teams incoming webhook
trigger:
  branches:
    include:
      - '{{branch}}'
pr: none
pool:
  vmImage: ubuntu-latest
jobs:
  - deployment: sfdt_release
    displayName: SFDT Release Deploy
    environment: {{environment}}
    strategy:
      runOnce:
        deploy:
          steps:
            - checkout: self
              fetchDepth: 0
            - task: NodeTool@0
              inputs:
                versionSpec: '{{nodeVersion}}'
            - script: npm install --global @salesforce/cli
              displayName: Install Salesforce CLI
            {{authSteps}}
            - script: |
                BASE=$(git describe --tags --abbrev=0 2>/dev/null || echo "{{deltaBase}}")
                echo "Deploying delta since $BASE"
                npx --yes @sfdt/cli@latest deploy --smart --org {{org}} --delta-base "$BASE" --notify
              displayName: Smart delta deploy
              env:
                SLACK_WEBHOOK_URL: $(SLACK_WEBHOOK_URL)
                TEAMS_WEBHOOK_URL: $(TEAMS_WEBHOOK_URL)
