name: Update the documentation

on:
  push:
    branches:
      - master

jobs:
  Building:
    runs-on: [ubuntu-latest]
    steps:
      - uses: actions/checkout@v1
      - uses: nikeee/docfx-action@v1.0.0
        name: Build Documentation
        with:
          args: docs/docfx.json
      - name: Update the docs
        run: |
          cd docs/_site
          sudo chown $(whoami):$(whoami) . -R
          echo -n docs.kyoo.moe > CNAME
          git config --global user.email "${GITHUB_ACTOR}@github.com"
          git config --global user.name "${GITHUB_ACTOR}"
          git init
          git add -A
          git commit -m "Deploying the documentation"
          git remote add origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${GITHUB_REPO}
          git checkout -b gh-pages
          git push --force origin gh-pages
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_REPO: "github.com/${{github.repository_owner}}/Kyoo"
