diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml
new file mode 100644
index 0000000..d241aeb
--- /dev/null
+++ b/.github/workflows/documentation.yml
@@ -0,0 +1,95 @@
+name: docs
+
+on:
+ push:
+ branches:
+ - master
+ tags:
+ - v*
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ ref: ${{github.ref}}
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install .[docs]
+ # [ -f docs/requirements.txt ] && pip install -r docs/requirements.txt || pip install sphinx sphinx-rtd-theme
+
+ - name: Set environment variable
+ run: |
+ echo ::set-env name=PROJECT_VERSION::$(echo ${GITHUB_REF##*/} | awk '{sub(/^master$/, "latest"); print}')
+ echo ::set-env name=GH_PAGES_BRANCH::$([ $(git ls-remote --quiet --heads origin gh-pages | wc -l) -ne 0 ] && echo 'gh-pages')
+
+ - name: Initialize the gh-pages branch
+ if: ${{!env.GH_PAGES_BRANCH}}
+ run: |
+ echo ::set-env name=GH_PAGES_BRANCH::gh-pages
+ git checkout --orphan gh-pages
+ git rm -rf .
+ touch .nojekyll
+ echo "latest" > all_versions.txt
+ echo '' > index.html
+ echo '' >> index.html
+ echo '
' >> index.html
+ echo ' ' >> index.html
+ echo ' Redirecting to latest' >> index.html
+ echo ' ' >> index.html
+ echo ' ' >> index.html
+ echo ' ' >> index.html
+ echo '' >> index.html
+ git add .nojekyll all_versions.txt index.html
+ git commit -m "Initial gh-pages commit"
+ git push "https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git" $GH_PAGES_BRANCH
+ git checkout ${GITHUB_REF##*/}
+
+ - name: Generate the documentation
+ run: |
+ cd docs
+ make html
+ cd ..
+
+ - name: Move the html files on gh-pages branches
+ run: |
+ git clean -df
+ git checkout $GH_PAGES_BRANCH
+ rm -rf $PROJECT_VERSION
+ mv docs/_build/html $PROJECT_VERSION
+ git add $PROJECT_VERSION
+
+ - name: Change the symlink of the stable release if necessary
+ if: startsWith(github.ref, 'refs/tags/v')
+ run: |
+ rm -f stable
+ ln -s $PROJECT_VERSION stable
+ git add stable
+
+ - name: Update the all_versions.txt file
+ if: startsWith(github.ref, 'refs/tags/v')
+ run: |
+ awk -v version=$PROJECT_VERSION 'NR==1 {print; print version}; NR!=1' all_versions.txt > ${{runner.temp}}/tmp.txt
+ mv ${{runner.temp}}/tmp.txt all_versions.txt
+ git add all_versions.txt
+
+ - name: Set the git status
+ id: git_status
+ run: echo ::set-output name=value::$(git diff-index --cached --quiet HEAD; echo $?)
+
+ - name: Commit and push changes
+ if: steps.git_status.outputs.value != 0
+ run: |
+ git commit -m "$PROJECT_VERSION doc build"
+ git push "https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git" $GH_PAGES_BRANCH