Skip to content

Commit 39ed5e3

Browse files
committed
Working action to generate Python docs
1 parent d0cac4f commit 39ed5e3

File tree

2 files changed

+61
-20
lines changed

2 files changed

+61
-20
lines changed

.github/workflows/publish-docs.yaml

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Publishes SDK docs to the docs-official repo (https://github.com/rungalileo/docs-official)
12
name: Publish Docs
23

34
on:
@@ -12,29 +13,75 @@ jobs:
1213
runs-on: ubuntu-latest
1314

1415
steps:
16+
# Checkout both this repo, and the docs official repo
1517
- name: Checkout
1618
uses: actions/checkout@v4
19+
with:
20+
path: ./galileo-python
1721

18-
- name: Install poetry
19-
run: pipx install poetry==${{ vars.POETRY_VERSION }}
22+
- name: Check out Docs repo
23+
uses: actions/checkout@v4
24+
with:
25+
repository: rungalileo/docs-official
26+
path: ./docs-official
27+
ref: feat/python-docs
28+
29+
# Install the GitHub CLI - this is needed to create a pull request against the docs
30+
- name: Install GH Cli
31+
run: |
32+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
33+
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
34+
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
35+
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
36+
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
37+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
38+
&& sudo apt update \
39+
&& sudo apt install gh -y
2040
41+
# Install Python
2142
- name: Set up Python
2243
uses: actions/setup-python@v5
2344
with:
2445
python-version: 3.11
25-
cache: "poetry"
26-
cache-dependency-path: "pyproject.toml"
2746

47+
# Install pydoc-markdown to generate the documentation
48+
- name: Install PyDoc
49+
run: pipx install pydoc-markdown
50+
51+
# Generate the docs using PyDoc
52+
# Then convert from md to mdx, and do some other tweaks to make them work with our docs
2853
- name: Build Docs
29-
# Install all dependencies so that the docs can use the function and type signatures.
54+
working-directory: ./galileo-python
3055
run: |
31-
pipx install invoke
32-
poetry install --all-extras --without test,dev
33-
invoke docs-build
56+
pydoc-markdown
57+
python ./scripts/convert-md-to-mdx.py
58+
59+
# Create a branch in the docs-official repo using the current branch name
60+
- name: Create a branch
61+
working-directory: ./docs-official
62+
run: git checkout -b feat/update-docs-${GITHUB_REF_NAME}
63+
64+
# Copy the generated docs from the Python SDK repo to the docs repo
65+
- name: Update SDK docs
66+
run: |
67+
rm -rf ./docs-official/sdk-api/python/reference
68+
cp -r ./galileo-python/.generated_docs/reference ./docs-official/sdk-api/python/
69+
70+
# Commit the changes to the branch, and push
71+
- name: Commit changes
72+
working-directory: ./docs-official
73+
run: |
74+
git config --global user.email "info@galileo.com"
75+
git config --global user.name "Galileo"
76+
git add .
77+
git commit -m "Updating docs from ${GITHUB_REF_NAME}"
78+
git push -u origin feat/update-docs-${GITHUB_REF_NAME}
79+
80+
# Create a PR against the docs repo with the new changes
81+
- name: Create PR
82+
working-directory: ./docs-official
83+
env:
84+
GH_TOKEN: ${{ github.token }}
85+
run: |
86+
gh pr create --title "Updated SDK docs" --body "Autogenerated update to SDK docs"
3487
35-
- name: Publish Docs
36-
uses: cloudflare/wrangler-action@v3
37-
with:
38-
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }}
39-
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
40-
command: pages deploy

tasks.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ def type_check(ctx: Context) -> None:
4646
)
4747

4848

49-
@task
50-
def docs_build(ctx: Context) -> None:
51-
ctx.run("pydoc-markdown", **COMMON_PARAMS)
52-
ctx.run("python ./scripts/convert-md-to-mdx.py", **COMMON_PARAMS)
53-
54-
5549
@task
5650
def poetry_lock(ctx: Context) -> None:
5751
"""

0 commit comments

Comments
 (0)