wip record doc versions

This commit is contained in:
Andrew Morgan 2022-05-05 12:00:22 +01:00
parent ba3fd54bad
commit 793a5bfd12
2 changed files with 55 additions and 1 deletions

View file

@ -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))

View file

@ -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