Polishing #61
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 MkDocs to GitHub Pages | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "autogen/**" | |
- "website/**" | |
- ".github/workflows/deploy-website.yml" | |
- ".github/workflows/docs-check-broken-links.yml" | |
- "scripts/broken-links-check.sh" | |
- "scripts/docs_build_mkdocs.sh" | |
- "scripts/docs_serve_mkdocs.sh" | |
- ".muffet-excluded-links.txt" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
fetch-depth: 0 | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "latest" | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
# Step 3: Build MkDocs | |
- name: Build documentation | |
run: | | |
uv venv | |
. .venv/bin/activate | |
uv pip install -e ".[docs]" | |
./scripts/docs_build_mkdocs.sh | |
ls -la ./website/mkdocs/site | |
working-directory: . | |
# Step 3: Configure Git user | |
- name: Configure Git user | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
# Step 4: Deploy to gh-pages branch | |
- name: Deploy to GitHub Pages | |
run: | | |
. .venv/bin/activate | |
# Get version directly from the package using a more reliable method | |
VERSION=$(python -c 'import os, sys; sys.path.insert(0, os.getcwd()); import autogen; print(".".join(autogen.__version__.split(".")[:3]))') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
# Check if version contains "rc" | |
IS_RC=$(python -c 'import os, sys; sys.path.insert(0, os.getcwd()); import autogen; print("rc" or "dev" in autogen.__version__)') | |
echo "IS_RC=$IS_RC" >> $GITHUB_ENV | |
echo $VERSION | |
echo $IS_RC | |
if [ "$IS_RC" == "False" ]; then | |
cd website/mkdocs && mike deploy -F mkdocs.yml --update-aliases $VERSION latest | |
mike set-default --push --allow-empty -F mkdocs.yml latest | |
else | |
cd website/mkdocs && mike deploy --push -F mkdocs.yml --update-aliases $VERSION | |
fi |