name: Deploy static site

on:
  push:
    branches: ["main"]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Deploy to shared pages
        env:
          OWNER: ${{ gitea.repository_owner }}
          REPO:  ${{ gitea.repository_name }}
        run: |
          TARGET="/target/${OWNER}/${REPO}"
          docker run --rm \
            -v pages_root:/target \
            -v "$PWD":/src \
            alpine:3.20 sh -lc '
              apk add --no-cache rsync >/dev/null &&
              mkdir -p "'"$TARGET"'" &&
              rsync -av --delete /src/ "'"$TARGET"'"/ \
                --exclude ".git" --exclude ".gitea"
            '
