name: Build and deploy content to environment server

on:
  push:
    branches: [dev, stg, prd]
    paths:
      - 'wp-content/*'
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    runs-on: ubuntu-latest

    environment:
      name: ${{ github.ref_name }}

    defaults:
      run:
        working-directory: ./

    steps:
      - uses: actions/checkout@v4

      - run: sshpass -p '${{ secrets.SSH_PASSWORD }}' rsync -e 'ssh -oStrictHostKeyChecking=no' -lr --exclude=wp-content/plugins/ --exclude=wp-content/themes/ wp-content/* ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_PATH }}/wp-content/
