Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs/deploy to branch #5

Merged
merged 11 commits into from
Jul 10, 2024
63 changes: 43 additions & 20 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
pages: write
id-token: write
steps:
Expand All @@ -37,22 +37,45 @@ jobs:
run: pip install tox-uv
- name: Build Docs ${{ inputs.force == true && '(Force)' || '' }}
run: tox -e docs-py310 ${{ inputs.force == true && '-- -f -r' || '-- -r' }}
- name: Upload docs artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'docs/build'

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- name: Prepare gh-pages branch with HTML output from Sphinx
run: |
git fetch origin gh-pages:gh-pages
git checkout gh-pages
if ${{ github.event_name == 'workflow_dispatch'}}; then
echo "Triggered by workflow_dispatch"
FOLDER='latest'
else
echo "Triggered by release"
FOLDER=${{github.event.release.tag_name}}
fi
echo "$FOLDER"
if [ -d $FOLDER ]; then
rm -rf ./$FOLDER
fi
mkdir ./$FOLDER
cp -rv docs/build/* ./$FOLDER
- name: Update gh-pages branch
run: |
if ${{ github.event_name == 'workflow_dispatch'}}; then
echo "Triggered by workflow_dispatch"
FOLDER='latest'
else
echo "Triggered by release"
FOLDER=${{github.event.release.tag_name}}
fi
git config --local user.email "sphinx-upload[bot]@users.noreply.github.com"
git config --local user.name "sphinx-upload[bot]"
git_hash=$(git rev-parse --short "$GITHUB_SHA")
git add -f $FOLDER
git commit --allow-empty -m "Sphinx documentation for ${git_hash}"
echo "Redirecting stable to newly released version"
rm stable
ln -sf $FOLDER stable
git add stable
git commit --allow-empty -m "redirect stable to new version $FOLDER"
echo "Inserting announcement banner to old documentation"
folder_names=$(find . -maxdepth 1 -type d -regex '\./[0-9].*')
python insert_banner.py "$folder_names"
git add .
git commit -m "Add announcement banner to old version"
git push origin gh-pages
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ License <misc/license_link>

User Guide <userguide/userguide>
Examples <examples/examples>
Versions <versions/versions>
```

# Indices and Tables
Expand Down
6 changes: 6 additions & 0 deletions docs/versions/versions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Versions

```{toctree}
Stable <https://avhopp.github.io/baybe_dev/stable/>
0.9.1 <https://avhopp.github.io/baybe_dev/0.9.1/>
```
Loading