Skip to content

Commit d4ec722

Browse files
feat: use CI GitHub env vars for docs metadata (#586)
This simplifies CI files, as the variables are available in the environment, and we don't need to pass them as arguments.
1 parent b129d4c commit d4ec722

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

.github/workflows/test_and_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555
pull-requests: write
5656
id-token: write
5757
with:
58-
bazel-target: "--lockfile_mode=error //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
58+
bazel-target: "//:docs"
5959
retention-days: 3
6060
tests-report-artifact: tests-report

src/incremental.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,8 @@ def update_module_hash(build_dir: Path, sentinel_files: list[Path]) -> None:
8080
parser.add_argument(
8181
"--debug", help="Enable Debugging via debugpy", action="store_true"
8282
)
83-
# optional GitHub user forwarded from the Bazel CLI
84-
parser.add_argument(
85-
"--github_user",
86-
help="GitHub username to embed in the Sphinx build",
87-
)
88-
parser.add_argument(
89-
"--github_repo",
90-
help="GitHub repository to embed in the Sphinx build",
91-
)
83+
parser.add_argument("--github_user", help=argparse.SUPPRESS)
84+
parser.add_argument("--github_repo", help=argparse.SUPPRESS)
9285
parser.add_argument(
9386
"--port",
9487
type=int,
@@ -140,12 +133,16 @@ def update_module_hash(build_dir: Path, sentinel_files: list[Path]) -> None:
140133
metamodel_yaml = os.path.abspath(metamodel_yaml)
141134
base_arguments.append(f"--define=score_metamodel_yaml={metamodel_yaml}")
142135

143-
# configure sphinx build with GitHub user and repo from CLI
144-
if args.github_user and args.github_repo:
145-
base_arguments.append(f"-A=github_user={args.github_user}")
146-
base_arguments.append(f"-A=github_repo={args.github_repo}")
136+
if github_repository := os.getenv("GITHUB_REPOSITORY"):
137+
# GITHUB_REPOSITORY is expected as "owner/repo"; partition("/") splits
138+
# once into (owner, separator, repo), so we can ignore the separator.
139+
github_user, _, github_repo = github_repository.partition("/")
140+
141+
base_arguments.append(f"-A=github_user={github_user}")
142+
base_arguments.append(f"-A=github_repo={github_repo}")
147143
base_arguments.append("-A=github_version=main")
148144
base_arguments.append(f"-A=doc_path={get_env('SOURCE_DIRECTORY')}")
145+
149146
if os.getenv("KNOWN_GOOD_JSON"):
150147
base_arguments.append(f"--define=KNOWN_GOOD_JSON={get_env('KNOWN_GOOD_JSON')}")
151148

0 commit comments

Comments
 (0)