redisvl_docs_sync #459
This file contains hidden or 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: redisvl_docs_sync | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # run every day at midnight UTC time | |
| workflow_dispatch: # or run on manual trigger | |
| jobs: | |
| define-version-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - id: set-matrix | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| OLDEST_SUPPORTED_VERSION="0.6.0" | |
| versions=$(gh release -R redis/redis-vl-python list --json name,isLatest \ | |
| | jq -r '.[] | [.name, .isLatest] | @tsv' \ | |
| | sed "/${OLDEST_SUPPORTED_VERSION}/q" \ | |
| | jq -Rnc '{include: [inputs | split("\t") | {version: .[0], isLatest: .[1]}]}') | |
| echo "${versions}" | |
| echo "matrix=${versions}" >> "$GITHUB_OUTPUT" | |
| redisvl_docs_sync: | |
| runs-on: ubuntu-latest | |
| needs: define-version-matrix | |
| strategy: | |
| matrix: ${{ fromJSON(needs['define-version-matrix'].outputs.matrix) }} | |
| fail-fast: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: write | |
| steps: | |
| - name: 'Checkout' | |
| uses: 'actions/checkout@v3' | |
| - name: 'Setup Python' | |
| uses: 'actions/setup-python@v5' | |
| with: | |
| python-version: '3.11' | |
| - name: 'Install deps' | |
| run: | | |
| pip3 install \ | |
| sphinx==8.1.3 \ | |
| sphinx_design==0.7.0 \ | |
| sphinx_copybutton==0.5.2 \ | |
| nbsphinx==0.9.7 \ | |
| sphinx_favicon==1.1.0 \ | |
| myst_nb==1.4.0 \ | |
| sphinx_markdown_builder==0.6.8 \ | |
| jupyter==1.1.1 | |
| - name: 'Fetch redisvl repo' | |
| run: | | |
| git clone https://github.com/redis/redis-vl-python | |
| - name: 'Sync redisvl docs' | |
| run: | | |
| version="${{ matrix.version }}" | |
| version="${version#v}" | |
| latest_flag="" | |
| if [ "${{ matrix.isLatest }}" = "true" ]; then | |
| latest_flag="--latest" | |
| fi | |
| python3 build/redisvl_docs_sync.py \ | |
| --version "${version}" \ | |
| --repo redis-vl-python \ | |
| ${latest_flag} | |
| - name: 'Create pull request if necessary' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| release="${{ matrix.version }}" | |
| release="${release#v}" | |
| branch="redisvl_docs_sync_${release}" | |
| redisvl_change=false | |
| # check if remote branch already exists | |
| git fetch --all | |
| set +e | |
| git ls-remote --exit-code --heads origin "refs/heads/${branch}" | |
| if [ "$?" -eq 0 ]; then | |
| set -e | |
| # if it does, create local branch off existing remote branch | |
| git checkout -f -b "${branch}" "origin/${branch}" | |
| git branch --set-upstream-to="origin/${branch}" "${branch}" | |
| git pull | |
| else | |
| set -e | |
| # otherwise, create local branch from main | |
| git checkout -b "${branch}" | |
| fi | |
| set +e | |
| latest_redisvl_release_is_different=$(git diff content/develop/ai/redisvl/ static/images/redisvl/) | |
| new_release=$(git ls-files --others --directory | grep -E 'content/develop/ai/redisvl/'${release}'|static/images/redisvl/') | |
| if [[ -n "$latest_redisvl_release_is_different" || -n "$new_release" ]]; then | |
| redisvl_change=true | |
| git add "content/develop/ai/redisvl/" | |
| git add "static/images/redisvl/" | |
| git config user.email "177626021+redisdocsapp[bot]@users.noreply.github.com" | |
| git config user.name "redisdocsapp[bot]" | |
| git commit -m "Update for redisvl ${release}" | |
| fi | |
| if [ "$redisvl_change" = true ] ; then | |
| git push origin "${branch}" | |
| # If a pr is not already open, create one | |
| set +e | |
| gh search prs -R redis/docs --state open --match title "update for redisvl ${release}" | grep -q "update for redisvl ${release}" | |
| if [ "$?" -eq 1 ]; then | |
| set -e | |
| gh pr create \ | |
| --body "update for redisvl ${release}" \ | |
| --title "update for redisvl ${release}" \ | |
| --head "$branch" \ | |
| --base "main" | |
| fi | |
| fi |