diff options
-rw-r--r-- | docs/README.md | 6 | ||||
-rw-r--r-- | docs/netlify_build.py | 32 |
2 files changed, 38 insertions, 0 deletions
diff --git a/docs/README.md b/docs/README.md index 06c5a739..fa719292 100644 --- a/docs/README.md +++ b/docs/README.md @@ -43,3 +43,9 @@ You can use [this site][releases] to get the PR number you'll use for your entry [next]: https://ichard26.github.io/next-pr-number/?owner=python-discord&name=bot-core [releases]: https://releases.readthedocs.io/en/latest/concepts.html + +## Static Builds +We deploy our docs to netlify to power static previews on PRs. +Check out [python-discord/site][STATIC_BUILD_DOCS] for more info on the system. + +[STATIC_BUILD_DOCS]: https://github.com/python-discord/site/tree/main/static-builds diff --git a/docs/netlify_build.py b/docs/netlify_build.py new file mode 100644 index 00000000..ca8f6d2e --- /dev/null +++ b/docs/netlify_build.py @@ -0,0 +1,32 @@ +# WARNING: This file must remain compatible with python 3.8 + +# This script performs all the actions required to build and deploy our project on netlify +# It depends on the following packages, which are set in the netlify UI: +# httpx == 0.19.0 + +import importlib +from pathlib import Path + +import httpx + +SCRIPT_SOURCE = "https://raw.githubusercontent.com/python-discord/site/main/static-builds/netlify_build.py" +OUTPUT = Path("docs/build.py") +OUTPUT.unlink(missing_ok=True) + +build_script = httpx.get(SCRIPT_SOURCE) +build_script.raise_for_status() +OUTPUT.write_text( + build_script.text.replace( + "Build & Publish Static Preview", + "Build Docs" + ).replace( + "static-build", + "docs" + ) +) + +script = importlib.import_module(OUTPUT.name.replace(".py", "").replace("/", ".")) + +if __name__ == "__main__": + print("Build started") + script.download_artifact(*script.get_build_artifact()) |