Skip to content

Commit 112932f

Browse files
authored
add cname attribute for custom-domain gh-pages deploy (#1060)
1 parent 12da7d8 commit 112932f

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
99

1010
## [Unreleased]
1111

12+
### Fixed
13+
14+
- Project-like that are inside a worksheet were not getting solutions in the backmatter.
15+
- Added an optional `cname` attribute on the `<project>` in the manifest to allow deploy to work with github pages using custom subdomains.
16+
1217
## [2.28.1] - 2025-08-18
1318

1419
Includes updates to core through commit: [5fd31db](https://github.com/PreTeXtBook/pretext/commit/5fd31dbe840afff119b45bffdaf0921bd7afb1ae)

pretext/project/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,9 @@ def server_validator(cls, v: t.List[Server]) -> t.List[Server]:
13131313
raise ValueError("Server names must not be repeated.")
13141314
return v
13151315

1316+
# cname attribute on project for writing into a `CNAME` file as part of a deploy.
1317+
cname: t.Optional[str] = pxml.attr(default=None)
1318+
13161319
# This validator sets the `_path`, which is provided in the validation context. It can't be loaded from the XML, since this is metadata about the XML (the location of the file it was loaded from).
13171320
# (It's unclear why the typing of the next line is causing issues.)
13181321
@model_validator(mode="after")
@@ -1727,7 +1730,7 @@ def deploy(
17271730
self.stage_deployment()
17281731
if not stage_only:
17291732
utils.publish_to_ghpages(
1730-
self.stage_abspath(), update_source, no_push=no_push
1733+
self.stage_abspath(), update_source, no_push=no_push, cname=self.cname
17311734
)
17321735

17331736
def is_git_managed(self) -> bool:

pretext/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,10 @@ def parse_git_remote(string: str) -> t.List[str]:
685685

686686

687687
def publish_to_ghpages(
688-
directory: Path, update_source: bool, no_push: bool = False
688+
directory: Path,
689+
update_source: bool,
690+
no_push: bool = False,
691+
cname: t.Optional[str] = None,
689692
) -> None:
690693
"""
691694
Publish the current project to GitHub pages.
@@ -774,7 +777,9 @@ def publish_to_ghpages(
774777
log.info("")
775778
# Should we let ghp_import do the push for us?
776779
# Should we remove the history?
777-
ghp_import.ghp_import(directory, mesg="Latest build deployed.", nojekyll=True)
780+
ghp_import.ghp_import(
781+
directory, mesg="Latest build deployed.", nojekyll=True, cname=cname
782+
)
778783
log.info(f"Attempting to connect to remote repository at `{origin.url}`...")
779784
# log.info("(Your SSH password may be required.)")
780785
log.info("")

0 commit comments

Comments
 (0)