Skip to content

Commit d3c6c3e

Browse files
authored
chore: Workflow to sync docs with Docusaurus repo (#9597)
* Remove state according to #9578 * Add workflow to sync API docs with Docusaurus repo
1 parent d8a0735 commit d3c6c3e

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Sync docs with Docusaurus
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- "docs/pydoc/config_docusaurus/**"
10+
- "haystack/**"
11+
- ".github/workflows/docusaurus_sync.yml"
12+
13+
env:
14+
HATCH_VERSION: "1.14.1"
15+
PYTHON_VERSION: "3.9"
16+
DOCS_REPO: "deepset-ai/haystack-docs"
17+
DOCS_REPO_PATH: "docs/api/haystack-api"
18+
19+
jobs:
20+
sync:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
25+
steps:
26+
- name: Checkout Haystack repo
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "${{ env.PYTHON_VERSION }}"
33+
34+
- name: Install Hatch
35+
run: pip install hatch==${{ env.HATCH_VERSION }}
36+
37+
- name: Generate API docs for Docusaurus
38+
# This command simply runs ./.github/utils/pydoc-markdown.sh with a specific config path
39+
run: hatch run readme:sync "../config_docusaurus/*"
40+
41+
- name: Checkout Docusaurus repo
42+
uses: actions/checkout@v4
43+
with:
44+
repository: ${{ env.DOCS_REPO }}
45+
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
46+
path: haystack-docs
47+
48+
- name: Sync generated docs to Docusaurus repo
49+
run: |
50+
SOURCE_PATH="docs/pydoc/temp"
51+
DEST_PATH="haystack-docs/${{ env.DOCS_REPO_PATH }}"
52+
53+
echo "Syncing from $SOURCE_PATH to $DEST_PATH"
54+
mkdir -p $DEST_PATH
55+
# Using rsync to copy files. This will also remove files in dest that are no longer in source.
56+
rsync -av --delete --exclude='.git/' "$SOURCE_PATH/" "$DEST_PATH/"
57+
58+
- name: Commit and push changes
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
61+
run: |
62+
git config --global user.name "github-actions[bot]"
63+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
64+
65+
cd haystack-docs
66+
67+
if [[ -n $(git status -s) ]]; then
68+
echo "Syncing docs with Docusaurus..."
69+
git add .
70+
git commit -m "docs: Sync Haystack API reference"
71+
git push
72+
else
73+
echo "No changes to sync with Docusaurus."
74+
fi

docs/pydoc/config_docusaurus/data_classess_api.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ loaders:
22
- type: haystack_pydoc_tools.loaders.CustomPythonLoader
33
search_path: [../../../haystack/dataclasses]
44
modules:
5-
["answer", "byte_stream", "chat_message", "document", "sparse_embedding", "state", "streaming_chunk"]
5+
["answer", "byte_stream", "chat_message", "document", "sparse_embedding", "streaming_chunk"]
66
ignore_when_discovered: ["__init__"]
77
processors:
88
- type: filter

0 commit comments

Comments
 (0)