API docs build #234
Workflow file for this run
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: API docs build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 13 * * *' | |
env: | |
PYTHON_VERSION: "3.11" | |
jobs: | |
build: | |
if: github.repository == 'langchain-ai/langchain' || github.event_name != 'schedule' | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: langchain | |
- uses: actions/checkout@v4 | |
with: | |
repository: langchain-ai/langchain-api-docs-html | |
path: langchain-api-docs-html | |
token: ${{ secrets.TOKEN_GITHUB_API_DOCS_HTML }} | |
- name: Get repos with yq | |
id: get-unsorted-repos | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq '.packages[].repo' langchain/libs/packages.yml | |
- name: Parse YAML and checkout repos | |
env: | |
REPOS_UNSORTED: ${{ steps.get-unsorted-repos.outputs.result }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Get unique repositories | |
REPOS=$(echo "$REPOS_UNSORTED" | sort -u) | |
# Checkout each unique repository that is in langchain-ai org | |
for repo in $REPOS; do | |
if [[ "$repo" != "langchain-ai/langchain" && "$repo" == langchain-ai/* ]]; then | |
REPO_NAME=$(echo $repo | cut -d'/' -f2) | |
echo "Checking out $repo to $REPO_NAME" | |
git clone --depth 1 https://github.com/$repo.git $REPO_NAME | |
fi | |
done | |
- name: Set up Python ${{ env.PYTHON_VERSION }} + uv | |
uses: "./langchain/.github/actions/uv_setup" | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install initial py deps | |
working-directory: langchain | |
run: | | |
uv venv | |
VIRTUAL_ENV=.venv uv pip install --upgrade --no-cache-dir pip setuptools pyyaml toml | |
- name: Move libs with script | |
run: VIRTUAL_ENV=.venv uv run python langchain/.github/scripts/prep_api_docs_build.py | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Rm old html | |
run: | |
rm -rf langchain-api-docs-html/api_reference_build/html | |
- name: Install dependencies | |
working-directory: langchain | |
run: | | |
VIRTUAL_ENV=.venv uv pip install $(ls ./libs/partners | xargs -I {} echo "./libs/partners/{}") --overrides ./docs/vercel_overrides.txt | |
VIRTUAL_ENV=.venv uv pip install libs/core libs/langchain libs/text-splitters libs/community libs/experimental libs/standard-tests | |
VIRTUAL_ENV=.venv uv pip install -r docs/api_reference/requirements.txt | |
- name: Set Git config | |
working-directory: langchain | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Github Actions" | |
- name: Build docs | |
working-directory: langchain | |
run: | | |
VIRTUAL_ENV=.venv uv run python docs/api_reference/create_api_rst.py | |
VIRTUAL_ENV=.venv uv run python -m sphinx -T -E -b html -d ../langchain-api-docs-html/_build/doctrees -c docs/api_reference docs/api_reference ../langchain-api-docs-html/api_reference_build/html -j auto | |
VIRTUAL_ENV=.venv uv run python docs/api_reference/scripts/custom_formatter.py ../langchain-api-docs-html/api_reference_build/html | |
# Default index page is blank so we copy in the actual home page. | |
cp ../langchain-api-docs-html/api_reference_build/html/{reference,index}.html | |
rm -rf ../langchain-api-docs-html/_build/ | |
# https://github.com/marketplace/actions/add-commit | |
- uses: EndBug/add-and-commit@v9 | |
with: | |
cwd: langchain-api-docs-html | |
message: 'Update API docs build' |