diff options
author | Andrew Morgan <andrewm@element.io> | 2022-05-05 12:00:22 +0100 |
---|---|---|
committer | Andrew Morgan <andrewm@element.io> | 2022-05-05 12:00:22 +0100 |
commit | 793a5bfd12976e938e9618ac0226472bba762f64 (patch) | |
tree | 5b29b3f608d9c86600d76746eb743339f750fea1 | |
parent | Remove unstable/unspecced login types. (#12597) (diff) | |
download | synapse-github/anoa/docs_version_picker.tar.xz |
wip record doc versions github/anoa/docs_version_picker anoa/docs_version_picker
-rwxr-xr-x | .ci/scripts/record_available_doc_versions.py | 28 | ||||
-rw-r--r-- | .github/workflows/docs.yaml | 28 |
2 files changed, 55 insertions, 1 deletions
diff --git a/.ci/scripts/record_available_doc_versions.py b/.ci/scripts/record_available_doc_versions.py new file mode 100755 index 0000000000..50480654fd --- /dev/null +++ b/.ci/scripts/record_available_doc_versions.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# This script will write a json file to $OUTPUT_FILE that contains the name of +# each available Synapse version with documentation. +# +# This script assumes that any top-level directory in the "gh-pages" branch is +# named after a documentation version and contains documentation website files. + +import os.path +import json + +OUTPUT_FILE = "versions.json" + +# Determine the list of Synapse versions that have documentation. +doc_versions = [] +for filepath in os.listdir(): + if os.path.isdir(filepath): + doc_versions.append(filepath) + +# Record the documentation versions in a json file, such that the +# frontend javascript is aware of what versions exist. +to_write = { + "versions": doc_versions, + "default_version": "latest", +} + +# Write the file. +with open(OUTPUT_FILE, "w") as f: + f.write(json.dumps(to_write)) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index b366eb8667..8d5d1b6e21 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -14,7 +14,7 @@ on: jobs: pages: - name: GitHub Pages + name: Build and deploy docs runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -63,3 +63,29 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./book destination_dir: ./${{ steps.vars.outputs.branch-version }} + + list_available_versions: + needs: pages + runs-on: ubuntu-latest + steps: + # Check out the current branch + - uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Save the script + run: cp .ci/scripts/record_available_doc_versions.py / + + - uses: actions/setup-python@v3 + + # Check out the gh-pages branch, which we'll be pushing the doc versions to + - uses: actions/checkout@v3 + with: + persist-credentials: false + # Check out the gh-pages branch + ref: 'gh-pages' + + - name: Record the available documentation versions + run: | + # Download the script + /record_available_doc_versions |