# Generated by `sfdt ci init --provider bitbucket --type scratch`.
# Merge this `pull-requests` pipeline into your bitbucket-pipelines.yml.
# Scratch-org CI: creates a fresh scratch org from the Dev Hub, deploys the
# source, runs local Apex tests (plus LWC tests when detected), and always
# deletes the org via after-script — pass or fail.
#
# {{org}} here is the DEV HUB alias: the auth secret must belong to a Dev Hub
# user with the "Salesforce DX Scratch Org" permissions.
#
# Required repository variables (Repository settings > Pipelines > Variables, secured):
{{authSecretsDoc}}
pipelines:
  pull-requests:
    '**':
      - step:
          name: SFDT Scratch Org CI
          image: {{image}}
          script:
            {{cliSetup}}
            {{authSteps}}
            - sf org create scratch --definition-file {{scratchDef}} --alias sfdt-ci --duration-days 1 --set-default --wait 20
            - sf project deploy start --target-org sfdt-ci --wait 30
            - sf apex run test --target-org sfdt-ci --test-level RunLocalTests --code-coverage --result-format human --wait 30
            {{lwcTestSteps}}
          after-script:
            - sf org delete scratch --target-org sfdt-ci --no-prompt || true
