# Generated by `sfdt ci init --provider github --type release`.
# Release deploy on push to {{branch}}: computes the changed-metadata delta since
# the last release tag and applies it to {{org}} — a real deploy, not a validation.
# The job runs in the '{{environment}}' GitHub Environment: add required reviewers
# there (Settings > Environments) to gate the deploy behind manual approval, and
# scope the auth secret to that environment.
#
# Delta base: the most recent tag (git describe). Tag each release — for example
# with `sfdt release <version>` or `sfdt deploy --tag` — 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 secrets (Settings > Secrets and variables > Actions):
{{authSecretsDoc}}
#   SLACK_WEBHOOK_URL    (optional) Slack incoming webhook for deploy notifications
#   TEAMS_WEBHOOK_URL    (optional) Microsoft Teams incoming webhook
name: SFDT Release Deploy
on:
  push:
    branches: ['{{branch}}']
  workflow_dispatch: {}
permissions:
  contents: read
jobs:
  release:
    runs-on: ubuntu-latest
    environment: {{environment}}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: '{{nodeVersion}}'
      - name: Install Salesforce CLI
        run: npm install --global @salesforce/cli
      {{authSteps}}
      - name: Smart delta deploy
        run: |
          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
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
          TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
