|
| 1 | +name: Sync API reference with Docusaurus |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+*" |
| 7 | + |
| 8 | + # Manual trigger: Use this ONLY if the automatic API reference sync failed during a release. |
| 9 | + # This will regenerate and sync the API reference to the Haystack repository. |
| 10 | + # WARNING: Running this workflow when this repository has evolved significantly since the release |
| 11 | + # will sync an incorrect API reference to Haystack. |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + generate-api-reference: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout this repo |
| 20 | + uses: actions/checkout@v5 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v6 |
| 24 | + with: |
| 25 | + python-version: "3.10" |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + python -m pip install --upgrade pip |
| 30 | + pip install -U haystack-pydoc-tools |
| 31 | +
|
| 32 | + - name: Generate API reference |
| 33 | + run: ./.github/utils/pydoc-markdown.sh "../config_docusaurus/*" |
| 34 | + |
| 35 | + - name: Upload API reference artifact |
| 36 | + uses: actions/upload-artifact@v4 |
| 37 | + with: |
| 38 | + name: experimental-api-reference |
| 39 | + path: docs/pydoc/temp |
| 40 | + if-no-files-found: error |
| 41 | + retention-days: 1 |
| 42 | + overwrite: true |
| 43 | + |
| 44 | + |
| 45 | + sync-api-reference: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: generate-api-reference |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Checkout Haystack repo |
| 51 | + uses: actions/checkout@v5 |
| 52 | + with: |
| 53 | + repository: deepset-ai/haystack |
| 54 | + ref: main |
| 55 | + token: ${{ secrets.HAYSTACK_BOT_TOKEN }} |
| 56 | + |
| 57 | + - name: Set up Python |
| 58 | + uses: actions/setup-python@v6 |
| 59 | + with: |
| 60 | + python-version: "3.10" |
| 61 | + |
| 62 | + - name: Download API reference artifact |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + name: experimental-api-reference |
| 66 | + path: temp_api_reference |
| 67 | + |
| 68 | + - name: Sync API reference |
| 69 | + run: | |
| 70 | + # Function to sync generated API reference to a destination |
| 71 | + sync_to_dest() { |
| 72 | + echo "Syncing to $1" |
| 73 | + mkdir -p "$1" |
| 74 | + rsync -av --delete --exclude='.git/' "temp_api_reference/" "$1/" |
| 75 | + } |
| 76 | +
|
| 77 | + # Sync to main reference |
| 78 | + sync_to_dest "docs-website/reference/experiments-api" |
| 79 | +
|
| 80 | + # Sync to all versioned directories |
| 81 | + if [ -d "docs-website/reference_versioned_docs" ]; then |
| 82 | + for version_dir in "docs-website/reference_versioned_docs"/version-*; do |
| 83 | + [ -d "$version_dir" ] && sync_to_dest "$version_dir/experiments-api" |
| 84 | + done |
| 85 | + fi |
| 86 | +
|
| 87 | + - name: Create Pull Request |
| 88 | + uses: peter-evans/create-pull-request@v7 |
| 89 | + with: |
| 90 | + token: ${{ secrets.HAYSTACK_BOT_TOKEN }} |
| 91 | + commit-message: "Sync Haystack Experimental API reference on Docusaurus" |
| 92 | + branch: sync-docusaurus-api-reference-experimental |
| 93 | + base: main |
| 94 | + title: "docs: sync Haystack Experimental API reference on Docusaurus" |
| 95 | + add-paths: | |
| 96 | + docs-website |
| 97 | + body: | |
| 98 | + This PR syncs the Haystack Experimental API reference on Docusaurus. Just approve and merge it. |
0 commit comments