Skip to content

Commit

Permalink
Fix docs/scripts/auto-generate-examples.py (#110)
Browse files Browse the repository at this point in the history
Hot-fix `docs/scripts/auto-generate-examples.py` script as the
`GITHUB_BRANCH` environment variable is empty, so rollback to use `main`
by default which is not ideal either since the PR examples won't have
working images, but lets tackle this on another PR later on.
  • Loading branch information
alvarobartt authored Oct 11, 2024
1 parent 186a198 commit 3373816
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/scripts/auto-generate-examples.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
import re

GITHUB_BRANCH = os.getenv("GITHUB_HEAD_REF", "main")


def process_readme_files():
print("Processing README.md files from examples/gke and examples/cloud-run...")
Expand Down Expand Up @@ -37,21 +35,21 @@ def process_file(root, file, dir):
# Replace image and link paths
content = re.sub(
r"\(\./(imgs|assets)/([^)]*\.png)\)",
rf"(https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/{GITHUB_BRANCH}/"
r"(https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/"
+ root
+ r"/\1/\2)",
content,
)
content = re.sub(
r"\(\.\./([^)]+)\)",
rf"(https://github.com/huggingface/Google-Cloud-Containers/tree/{GITHUB_BRANCH}/examples/"
r"(https://github.com/huggingface/Google-Cloud-Containers/tree/main/examples/"
+ dir
+ r"/\1)",
content,
)
content = re.sub(
r"\(\.\/([^)]+)\)",
rf"(https://github.com/huggingface/Google-Cloud-Containers/tree/{GITHUB_BRANCH}/"
r"(https://github.com/huggingface/Google-Cloud-Containers/tree/main/"
+ root
+ r"/\1)",
content,
Expand Down

0 comments on commit 3373816

Please sign in to comment.