# This github-Evennia workflow will build the docs.

name: documentation

on:
  push:
    branches: [ main, develop ]
    paths:
      - 'docs/**'
      - 'evennia/contrib/**'
  pull_request:
    branches: [ main, develop ]
    paths:
      - 'docs/**'
      - 'evennia/contrib/**'

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python-version: ['3.10']

    steps:
      - name: Checkout ${{ github.ref }} branch 
        uses: actions/checkout@v3

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip

      - name: Install doc-building dependencies
        run: |
          python -m pip install --upgrade pip
          cd docs/
          make install

      # full game dir needed for mv-local
      - name: Set up evennia game dir
        run: |
          pip install .
          pip install .[extra]
          cd ..
          evennia --init gamedir
          cd gamedir
          evennia migrate

      - name: Build and deploy docs (only from main/develop branch)
        if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'}}
        run: |
          git config --global user.email "docbuilder@evennia.com"
          git config --global user.name "Evennia docbuilder action"
          git branch
          cd docs
          make release
