name: MkDocs Build and Deploy
run-name: ${{ gitea.actor }} is deploying U.10 Makerspace site 🚀
on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3
      - name: Install Python
        run: apt-get update && apt-get install python3-pip python3-venv -y
      - name: Build MkDocs site
        run: |
          pip install mkdocs
          pip install mkdocs-material
          pip install "mkdocs-material[imaging]"
          pip install mkdocs-macros-plugin
          pip install mkdocs-glightbox
          pip install mkdocs-include-markdown-plugin
          pip install mkdocs-video
          pip install mkdocs-rss-plugin
          pip install mkdocs-snippets
          pip install mkdocs-exclude
          pip install mkdocs-minify-plugin
          mkdocs build
      - name: Set google verification
        env:
          GOOGLE_VERIFICATION: ${{ vars.U10_GOOGLE_SITE_VERIFICATION }}
        run: |
          echo google-site-verification: $GOOGLE_VERIFICATION > ./site/$GOOGLE_VERIFICATION
      - name: Install lftp
        run: apt-get install lftp -y
      - name: Deploy MkDocs site
        env:
          FTP_USERNAME: ${{ vars.U10_FTP_USER }}
          FTP_PASSWORD: ${{ secrets.U10_FTP_PASSWORD }}
          FTP_SERVER: ${{ vars.U10_FTP_SERVER }}
        run: |
          lftp -c "set ftp:ssl-allow no; open '$FTP_SERVER'; user '$FTP_USERNAME' '$FTP_PASSWORD'; mirror --reverse --delete --verbose ./site /; bye"
