develop (#27) #14
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: Auto-documentation Generation | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'pydbsmgr/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
generate-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install pdoc3 | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
pip install pdoc3 | |
- name: Set up Git | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
GITHUB_NAME: ${{ secrets.NAME }} | |
GITHUB_EMAIL: ${{ secrets.EMAIL }} | |
run: | | |
git config user.email "${GITHUB_EMAIL}" | |
git config user.name "${GITHUB_NAME}" | |
git config credential.helper "store --file=.git/credentials" | |
echo "https://${{ secrets.TOKEN }}@github.com/${{ github.repository }}" > .git/credentials | |
- name: Remove existing documentation files | |
run: rm -rf docs/* | |
- name: Retrieve package name | |
id: get_package_name | |
run: | | |
name=$(python setup.py --name) | |
echo "::set-output name=name::$name" | |
- name: Generate documentation | |
run: | | |
pdoc --html . --output-dir docs | |
- name: Copy documentation files | |
run: | | |
cp -r docs/${{ steps.get_package_name.outputs.name }}/* docs/ | |
rm -rf docs/${{ steps.get_package_name.outputs.name }} | |
- name: Commit documentation changes | |
run: | | |
if git status --porcelain | grep .; then | |
echo "Changes detected, proceeding with workflow steps..." | |
git add docs/ | |
git commit -m "Auto-generated documentation" | |
git push origin main | |
else | |
echo "No changes detected, skipping workflow steps." | |
fi |