Skip to content

Fix target type (#133) #246

Fix target type (#133)

Fix target type (#133) #246

Workflow file for this run

name: Publish Docs to gh-pages
on: [push, workflow_dispatch]
env:
POETRY_VERSION: '1.4.2'
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/actions-poetry@v2.1.5
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 foxai && 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 github-actions@github.com
- 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