name: Deploy preview (main_xxx)

on:
  push:
    branches:
      - 'main_*'     # 通配所有 main_xxx 分支
  workflow_dispatch:

concurrency:
  group: deploy-${{ github.ref_name }}   # 同一分支串行
  cancel-in-progress: true

jobs:
  deploy:
    name: Deploy ${{ github.ref_name }}
    runs-on: ["native"]
    steps:
      - uses: actions/checkout@v4

      - name: Set BRANCH env
        shell: bash
        run: |
          BR="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}"
          echo "BRANCH=$BR" >> "$GITHUB_ENV"
          echo "Branch: $BR"

      - name: Deploy to preview
        run: /usr/local/bin/deploy_branch_simple.sh
