Skip to content

Commit

Permalink
Merge pull request #59 from softwaremill/feat/docs-gh-pages
Browse files Browse the repository at this point in the history
Documentation in multiple versions on gh-pages #27
  • Loading branch information
adamjankaczmarek authored Feb 13, 2023
2 parents e625241 + 75214be commit 9da4963
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 2 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/publish_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Publish Docs to gh-pages
on: [push, workflow_dispatch]

env:
POETRY_VERSION: '1.2.1'
PYTHON_VERSION: '3.8'
jobs:
build_docs:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ".venv"
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}--${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}
venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-
- name: Setup poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ env.POETRY_VERSION }}

- name: Install dependencies
shell: bash
run: |
poetry install --with docs
working-directory: ""

- name: Get Package Version
id: get_version
run: echo ::set-output name=VERSION::$(poetry version | cut -d " " -f 2)

- name: Build docs
run: poetry run sphinx-apidoc -o docs/source autoxai && cd docs && poetry run make html

- name: Compress production artifacts
run: tar -czvf docs/build/foxai-docs-${{ steps.get_version.outputs.VERSION }}.tar.gz docs/build/html/

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: foxai-docs
path: docs/build/foxai-docs-${{ steps.get_version.outputs.VERSION }}.tar.gz



deploy_gh_pages:
runs-on: ubuntu-latest
name: Deploy documentation to gh-pages
if: always() && needs.build_docs.result == 'success' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
needs: [build_docs]
steps:

- uses: actions/setup-python@v2
name: Install Python ${{ env.PYTHON_VERSION }}
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install deploy requirements
run: pip install docs-versions-menu

- name: Get branch name
shell: bash
run: |
echo ${{ github.ref }}
echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV
cat $GITHUB_ENV
- uses: actions/checkout@v3
name: Check out gh-pages branch (full history)
with:
ref: gh-pages
fetch-depth: 0

- uses: actions/download-artifact@v2
name: Download foxai-docs artifact
with:
name: foxai-docs
path: _foxai_docs

- name: Unzip html documentation
working-directory: _foxai_docs
shell: bash
run: |
mkdir _unzip
mkdir _unzip/${{ env.BRANCH_NAME }}
tar -xvf *.tar.gz -C _unzip
rm *.tar.gz
mv _unzip/docs/build/html/* _unzip/${{ env.BRANCH_NAME }}
- name: Rsync html documentation into place
run: rsync -av --delete _foxai_docs/_unzip/${{ env.BRANCH_NAME }}/ ./${{ env.BRANCH_NAME }}/

- name: Remove artifact files
shell: bash
run: rm -rf _foxai_docs

- name: Run docs-versions-menu
run: docs-versions-menu

- name: Set git configuration
shell: bash
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Commit changes
shell: bash
run: |
echo "Committing to gh-pages"
echo "# GIT ADD"
git add -A --verbose
echo "# GIT STATUS"
git status
echo "# GIT COMMIT"
git commit --verbose -m "Auto-update from Github Actions Workflow" -m "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})"
git log -n 1
- name: Push changes
run: git push --verbose
4 changes: 2 additions & 2 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Installation
============

First we must make sure we have ``autoxai`` installed:
First we must make sure we have ``foxai`` installed:

.. code-block:: bash
$ python -m pip install autoxai
$ python -m pip install foxai
Installation from source
Expand Down

0 comments on commit 9da4963

Please sign in to comment.