Skip to content

Commit 6ae7868

Browse files
Use New Static Build Site API (#122)
Updates the build the script to use the new API provided by the site to fetch and download artifacts. Additionally, metadata files are deleted in CI. They are only required for speeding up subsequent builds, which is not applicable in CI, and only increases the build size.
1 parent c7a6ddd commit 6ae7868

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

.github/workflows/docs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ jobs:
5858
BUILD_DOCS_FOR_HEAD: ${{ github.event_name == 'pull_request' }}
5959
BRANCH_NAME: ${{ github.head_ref }}
6060

61+
- name: Remove Metadata Files
62+
run: |
63+
rm -r docs/build/**/_sources
64+
rm -r docs/build/**/.doctrees
65+
6166
- name: Upload Build Artifact
6267
uses: actions/upload-artifact@v2
6368
with:

docs/netlify_build.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,25 @@
22

33
# This script performs all the actions required to build and deploy our project on netlify
44
# It depends on the following packages, which are set in the netlify UI:
5-
# httpx == 0.19.0
5+
# httpx == 0.23.0
66

7-
import importlib
7+
import subprocess
8+
import sys
89
from pathlib import Path
910

1011
import httpx
1112

12-
SCRIPT_SOURCE = "https://raw.githubusercontent.com/python-discord/site/main/static-builds/netlify_build.py"
13+
# Clean up environment
1314
OUTPUT = Path("docs/build.py")
1415
OUTPUT.unlink(missing_ok=True)
1516

17+
# Download and write the build script
18+
SCRIPT_SOURCE = "https://raw.githubusercontent.com/python-discord/site/main/static-builds/netlify_build.py"
1619
build_script = httpx.get(SCRIPT_SOURCE)
1720
build_script.raise_for_status()
18-
OUTPUT.write_text(
19-
build_script.text.replace(
20-
"Build & Publish Static Preview",
21-
"Build Docs"
22-
).replace(
23-
"static-build",
24-
"docs"
25-
)
26-
)
27-
28-
script = importlib.import_module(OUTPUT.name.replace(".py", "").replace("/", "."))
21+
OUTPUT.write_text(build_script.text, encoding="utf-8")
2922

3023
if __name__ == "__main__":
24+
# Run the build script
3125
print("Build started")
32-
script.download_artifact(*script.get_build_artifact())
26+
subprocess.run([sys.executable, OUTPUT.absolute()])

0 commit comments

Comments
 (0)