rebuild and update docs #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy API Documentation | |
on: | |
push: | |
branches: | |
- main # or your primary branch | |
jobs: | |
deploy-docs: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout the repository. | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# 2. Set up Python. | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
# 3. Install pydoctor. | |
- name: Install pydoctor | |
run: | | |
pip install pydoctor | |
# 4. Build the API documentation using pydoctor. | |
# This command tells pydoctor to generate HTML docs in docs/api for the module tensorgrad. | |
- name: Build API Documentation with Pydoctor | |
run: | | |
pydoctor --html-output=docs/api tensorgrad/ | |
# 5. Deploy the generated documentation to the gh-pages branch. | |
- name: Deploy API Documentation to gh-pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GIT_USER: "GitHub Action" | |
GIT_EMAIL: "action@github.com" | |
GITHUB_REPOSITORY: ${{ github.repository }} | |
run: | | |
# Directory with newly built API docs. | |
DOCS_API_DIR=docs/api | |
# Clone the gh-pages branch into a temporary folder. | |
git clone --branch gh-pages "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages-temp | |
cd gh-pages-temp | |
# Remove the old API documentation folder. | |
rm -rf docs/api | |
# Ensure the docs folder exists. | |
mkdir -p docs | |
# Copy in the newly built API documentation. | |
cp -R ../${DOCS_API_DIR} docs/api | |
# Configure Git. | |
git config user.name "${GIT_USER}" | |
git config user.email "${GIT_EMAIL}" | |
# Stage and commit the changes. | |
git add docs/api | |
git commit -m "Update API documentation [skip ci]" || echo "No changes to commit" | |
# Push the updated gh-pages branch. | |
git push origin gh-pages |