name: Deploy to WordPress.org

on:
  push:
    tags:
      - "*"

concurrency:
  group: deploy-${{ github.ref }}
  cancel-in-progress: true

jobs:
  tag:
    name: New tag
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Setup Node
        uses: actions/setup-node@v5
        with:
          node-version: 20
          cache: 'npm'
          cache-dependency-path: package-lock.json

      - name: Restore node_modules
        id: node-modules-cache
        uses: actions/cache@v5
        with:
          path: node_modules
          key: ${{ runner.os }}-node-20-modules-${{ hashFiles('package-lock.json') }}

      - name: Install dependencies
        if: steps.node-modules-cache.outputs.cache-hit != 'true'
        run: npm ci --prefer-offline --no-audit --no-fund

      - name: Build
        run: npm run build

      - name: WordPress Plugin Deploy
        uses: 10up/action-wordpress-plugin-deploy@stable
        env:
          SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
          SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
