Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
keras-team
GitHub Repository: keras-team/keras-io
Path: blob/master/scripts/upload_to_gcs.py
3273 views
1
"""Script to upload post-build `site/` contents to GCS.
2
3
Prerequisite steps:
4
5
```
6
gcloud auth login
7
gcloud config set project keras-io
8
```
9
10
The site can be previewed at http://keras.io.storage.googleapis.com/index.html
11
12
NOTE that when previewing through the storage.googleapis.com URL,
13
there is no redirect to `index.html` or `404.html`; you'd have to navigate directly
14
to these pages. From the docs:
15
16
```
17
The MainPageSuffix and NotFoundPage website configurations
18
are only used for requests that come to Cloud Storage through a CNAME or A redirect.
19
For example, a request to www.example.com shows the index page,
20
but an equivalent request to storage.googleapis.com/www.example.com does not.
21
```
22
23
After upload, you may need to invalidate the CDN cache.
24
"""
25
26
import os
27
import pathlib
28
29
bucket = "keras.io" # Bucket under `keras-io` project
30
scripts_path = pathlib.Path(os.path.dirname(__file__))
31
base_path = scripts_path.parent
32
site_path = base_path / "site"
33
site_dir = site_path.absolute()
34
35
os.system(f"gsutil -m rsync -R {site_dir} gs://{bucket}")
36
37