name: Docs

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Setup Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Checkout Pygments
      uses: actions/checkout@v1
    - name: Install Sphinx
      run: pip install Sphinx
    - name: Create Pyodide WASM package
      uses: ./.github/actions/pyodide-package
    - name: Sphinx build
      run: |
        cd doc
        WEBSITE_BUILD=1 make dirhtml
        cp -a ../pyodide _build/dirhtml/_static
        touch _build/dirhtml/.nojekyll
        echo -e 'pygments.org\nwww.pygments.org' > _build/dirhtml/CNAME
        echo 'Automated deployment of docs for GitHub pages.' > _build/dirhtml/README
    - name: Deploy to repo
      uses: peaceiris/actions-gh-pages@v2.5.0
      env:
        ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
        EXTERNAL_REPOSITORY: pygments/pygments.github.io
        PUBLISH_BRANCH: master
        PUBLISH_DIR: ./doc/_build/dirhtml
