haystack/.github/workflows/readme_sync.yml
Stefano Fiorucci 52d36062d4
Revert "chore(deps): bump actions/checkout from 5 to 6 (#10118)" (#10120)
This reverts commit 6d0660aec1c33409a4e92e13eba130c0fb1584b0.
2025-11-21 15:27:41 +01:00

67 lines
2.1 KiB
YAML

name: Sync docs with Readme
on:
pull_request:
paths:
- "docs/pydoc/**"
# TODO: remove this workflow once migration to Docusaurus is complete
# push:
# branches:
# - main
# # release branches have the form v1.9.x
# - "v[0-9]+.[0-9]+.x"
# # Exclude 1.x release branches, there's another workflow handling those
# - "!v1.[0-9]+.x"
env:
HATCH_VERSION: "1.14.2"
PYTHON_VERSION: "3.10"
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install Hatch
run: pip install "hatch==${{ env.HATCH_VERSION }}"
- name: Generate API docs
env:
# This is necessary to fetch the documentation categories
# from Readme.io as we need them to associate the slug
# in config files with their id.
README_API_KEY: ${{ secrets.README_API_KEY }}
# The command is a bit misleading, we're not actually syncing anything here,
# we're just generating the markdown files from the yaml configs.
run: hatch run readme:sync
- name: Get version
id: version-getter
run: |
VERSION="$(hatch version | cut -d '.' -f 1,2)"
CURRENT_BRANCH="${{ github.ref_name }}"
# If we're on `main` branch we should push docs to the unstable version
if [ "$CURRENT_BRANCH" = "main" ]; then
VERSION="$VERSION-unstable"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Sync docs
if: github.event_name == 'push'
uses: readmeio/rdme@v9
with:
rdme: docs ./docs/pydoc/temp --key=${{ secrets.README_API_KEY }} --version=${{ steps.version-getter.outputs.version }}
- name: Delete outdated
if: github.event_name == 'push'
env:
README_API_KEY: ${{ secrets.README_API_KEY }}
run: hatch run readme:delete-outdated --version="${{ steps.version-getter.outputs.version }}" --config-path ./docs/pydoc/config