diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 542174d9e..41849368f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,8 +12,19 @@ jobs: agregate: name: Agregate build artifacts runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + container: + image: ghcr.io/texasinstruments/processor-sdk-doc:latest + options: --entrypoint /bin/bash steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Add directory to safe dir overrides + run: | + git config --global --add safe.directory "$PWD" + - name: Download all artifacts uses: actions/download-artifact@v4 with: @@ -23,36 +34,7 @@ jobs: run-id: ${{ github.event.workflow_run.id }} - name: Generate root index - run: | - cat << EOF > build/index.html - - - - - PSDK Documentation Landing Page - - -
-

PSDK Documentation Landing Page

- -
- - - EOF + run: ./bin/root_index.py - name: Upload static files as single artifact uses: actions/upload-pages-artifact@v3 diff --git a/bin/root_index.html b/bin/root_index.html new file mode 100644 index 000000000..774bc06f7 --- /dev/null +++ b/bin/root_index.html @@ -0,0 +1,23 @@ + + + + + + PSDK Documentation Landing Page + + +
+

PSDK Documentation Landing Page

+

+ The following documentation is currently available: +

+ +
+ + diff --git a/bin/root_index.py b/bin/root_index.py new file mode 100755 index 000000000..79d0e2dd8 --- /dev/null +++ b/bin/root_index.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 + +"""Tool to find and make a index of doc root index files + +SPDX-License-Identifier: MIT +Copyright (C) 2025 Texas Instruments Incorporated - https://www.ti.com +""" + +from pathlib import Path +import logging +from jinja2 import Environment, FileSystemLoader + +BUILD_PATH = Path("build/") +TEMPLATE_PATH = Path(__file__).parent + +logger = logging.getLogger(__name__) + + +def get_root_index(path): + """Get the root index from a list of candidates + + :param path: Pathlib path to search in + """ + candidates = [x for x in path.glob("**/index.html") if x.is_file()] + if not candidates: + return None + + sorted_paths = sorted(candidates, key=lambda x: len(x.parts)) + return sorted_paths[0] + + +def get_index_list(): + """Get the list of index files to use from the build directory""" + index_list = [] + for path in BUILD_PATH.glob("*/"): + root = get_root_index(path) + if root: + logging.info("Found index: %s", root) + root = root.relative_to(BUILD_PATH) + logging.info("Updating path to: %s", root) + index_list.append(root) + return sorted(index_list) + + +def generate_root_index(index_list): + """Make the root index file + + :param index_list: List of pathlib paths to indexes + """ + root_index_path = BUILD_PATH.joinpath("index.html") + logging.info("Loading jinja env") + env = Environment(loader=FileSystemLoader(TEMPLATE_PATH)) + template = env.get_template("root_index.html") + logging.info("Using template: %s", template.name) + output = template.render(path_list=index_list) + logging.info("Writing output to: %s", root_index_path) + with root_index_path.open("w", encoding="utf-8") as f: + f.write(output) + + +def main(): + """Main processing loop""" + logging.basicConfig(level=logging.INFO) + index_list = get_index_list() + generate_root_index(index_list) + + +if __name__ == "__main__": + main()