Skip to content

Commit f5e75f1

Browse files
committed
Allow overriding site url in CI
1 parent bd10e92 commit f5e75f1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.github/workflows/hexdoc.yml

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
description: Subdirectory to deploy the book to
2828
type: string
2929
required: false
30+
site-url:
31+
description: Set the base site url instead of looking up the current repo's GitHub Pages url
32+
type: string
33+
required: false
3034
bump-version-segment:
3135
description: DEPRECATED - This value no longer does anything and is only kept for backwards compatibility.
3236
type: string
@@ -49,6 +53,7 @@ env:
4953
HEXDOC_PROPS: ${{ inputs.props }}
5054
HEXDOC_RELEASE: ${{ inputs.release }}
5155
HEXDOC_SUBDIRECTORY: ${{ inputs.subdirectory }}
56+
GITHUB_PAGES_URL: ${{ inputs.site-url }}
5257

5358
jobs:
5459
build:

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
99
### Added
1010

1111
* hexdoc now uses a custom `sys.excepthook` to hide unnecessary traceback frames, except in verbose mode.
12+
* New reusable workflow input `site-url` to help support non-Pages deployments.
1213

1314
### Changed
1415

1516
* Adding spoilers to individual pages with the `advancement` field is now supported.
1617
* Use [`uv`](https://github.com/astral-sh/uv) instead of `pip` for all reusable workflows.
18+
* `hexdoc ci build` now attempts to read the site url from `HEXDOC_SITE_URL` and `GITHUB_PAGES_URL` environment variables before querying the GitHub API.
1719

1820
## `1!0.1.0a10`
1921

src/hexdoc/cli/ci.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ def build(
3434
env = CIEnvironment.model_getenv()
3535
setup_logging(env.verbosity, ci=True)
3636

37-
if not (pages_url := os.getenv("MOCK_GITHUB_PAGES_URL")):
37+
# FIXME: scuffed. why are we setting environment variables here :/
38+
for key in [
39+
"MOCK_GITHUB_PAGES_URL", # highest priority so tests work correctly
40+
"HEXDOC_SITE_URL", # TODO: this should be supported in more places
41+
"GITHUB_PAGES_URL",
42+
]:
43+
if pages_url := os.getenv(key):
44+
break
45+
else:
3846
pages_url = get_pages_url(env.repo)
39-
os.environ["GITHUB_PAGES_URL"] = pages_url
47+
os.environ["GITHUB_PAGES_URL"] = pages_url
4048

4149
site_path = hexdoc_app.build(
4250
Path("_site/src/docs"),

0 commit comments

Comments
 (0)