diff options
author | 2022-01-09 19:59:29 +0200 | |
---|---|---|
committer | 2022-01-09 19:59:29 +0200 | |
commit | 29189d599f7de9f87aeba3f565f0efd0aae5c690 (patch) | |
tree | bd331b7d287a4863d65102ee300b3f0f5706edee /docs/netlify_build.py | |
parent | Merge pull request #12 from python-discord/add-code-block-regex (diff) |
Add Doc Static Previews With Netlify
Adds a helper script which downloads and calls the netlify build script
from the site project, to enable static previews for docs.
Diffstat (limited to 'docs/netlify_build.py')
-rw-r--r-- | docs/netlify_build.py | 32 |
1 files changed, 32 insertions, 0 deletions
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()) |