name: Deploy static portfolio (public sample)

on:
  push:
    branches: [master]
  workflow_dispatch:

permissions:
  contents: read
  id-token: write

concurrency:
  group: static-portfolio-${{ github.ref }}
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      AZURE_CORE_OUTPUT: none
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          persist-credentials: false
      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '22.23.2'
          cache: npm
          cache-dependency-path: package-lock.json
      - name: Install dependencies
        run: npm ci
      - name: Validate
        run: npm run validate
      - name: Build
        run: npm run build
      - name: Verify build output
        run: |
          test -d dist
          test -f dist/index.html
      - name: Azure login
        uses: azure/login@v3
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      - name: Upload to Azure Storage
        run: |
          az storage blob upload-batch \
            --account-name <STORAGE_ACCOUNT_NAME> \
            --destination '$web' \
            --source dist \
            --auth-mode login \
            --overwrite true \
            --only-show-errors
      - name: Azure logout
        if: always()
        run: az logout
