name: Deploy to WordPress.org
on:
  push:
    tags:
    - "*"
jobs:
  tag:
    name: New tag
    runs-on: ubuntu-latest
    steps:
    - name: checkout source
      uses: actions/checkout@v2
    - name: generate lfs file list
      run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
    - name: restore lfs cache
      uses: actions/cache@v2
      id: lfs-cache
      with:
        path: .git/lfs
        key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
    - name: pull lfs files
      run: git lfs pull
    - name: Build
      run: |
        npm install
        npm run build
        cd "$GITHUB_WORKSPACE"
        # Ensure built stuff is included in this temporary workspace
        # repo, as the deploy script will send it to SVN from here.
        # - Just make sure this doesn't get pushed back upstream
        git config --global user.email "deploybot@example.com"
        git config --global user.name "DeployBot on GitHub"
        git add --force build/fonts/* && git commit -m "Add any font files"
        git add --force build/* && git commit -m "Add built code"
        cd -
    - name: WordPress Plugin Deploy
      uses: 10up/action-wordpress-plugin-deploy@stable
      env:
        SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
        SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
        SLUG: math-input-with-mathquill
        ASSETS_DIR: wordpress-org
