Skip to content

Commit fb71944

Browse files
ci(build): preview PR builds via Read the Docs
1 parent 7607221 commit fb71944

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
version: 2
6+
7+
build:
8+
os: ubuntu-24.04
9+
tools:
10+
ruby: "3.3"
11+
commands:
12+
- |
13+
chmod +x "./scripts/readthedocs_build.sh"
14+
"./scripts/readthedocs_build.sh"
15+
16+
submodules:
17+
include: all
18+
recursive: true

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,34 @@ jobs:
6666
```
6767
6868
For additional options see [jekyll-build.yml](.github/workflows/jekyll-build.yml)
69+
70+
### PR Previews
71+
72+
Changes to gh-pages can be previewed, by setting up the project in ReadTheDocs.
73+
It is recommended to use the following manual configuration:
74+
75+
Initial setup:
76+
```yml
77+
Name: LizardByte-gh-pages-<repo_name> # the project slug cannot be changed after creation
78+
Repository URL: https://github.com/LizardByte/<repo_name>.git
79+
Default-branch: master
80+
Language: English
81+
```
82+
83+
Project Settings:
84+
```yml
85+
Connected-repository: https://github.com/LizardByte/<repo_name>.git
86+
URL-versioning-scheme: Multiple versions without translations
87+
Path-for-.readthedocs.yaml: # only set if not in the root of the repo
88+
Programming-Language: Other
89+
Project-homepage: https://app.lizardbyte.dev/<repo_name>
90+
Description: Preview PRs for gh-pages
91+
Build-pull-requests-for-this-project: true
92+
```
93+
94+
Additionally, do the following:
95+
96+
1. Deactivate the `stable` version
97+
2. Make the `latest` version hidden
98+
3. Add project as a subproject of `LizardByte-gh-pages-main`
99+
4. Update branch protection rules in GitHub repo settings to require status checks from ReadTheDocs

scripts/readthedocs_build.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# set default directories
5+
project_dir="."
6+
theme_dir="."
7+
8+
# TODO: make this work for subproject gh-pages
9+
# if not the theme project then we need to clone the theme with submodules
10+
if [ "$READTHEDOCS_PROJECT" != "lizardbytegithubio" ]; then
11+
theme_dir="theme"
12+
git clone --depth 1 https://github.com/LizardByte/LizardByte.github.io.git ${theme_dir} --recurse-submodules
13+
fi
14+
15+
TMPDIR=$(pwd)/../tmp
16+
mkdir -p ${TMPDIR}
17+
18+
base_dirs=(
19+
${theme_dir}/third-party/beautiful-jekyll
20+
${theme_dir}
21+
)
22+
23+
targets=(
24+
*.gemspec
25+
_data
26+
_includes
27+
_layouts
28+
_sass
29+
assets
30+
404.html
31+
_config_theme.yml
32+
favicon.ico
33+
feed.xml
34+
Gemfile
35+
staticman.yml
36+
tags.html
37+
)
38+
39+
for base_dir in "${base_dirs[@]}"; do
40+
for target in "${targets[@]}"; do
41+
if [ -e "$base_dir/$target" ]; then
42+
cp -rf "$base_dir/$target" ${TMPDIR}/
43+
fi
44+
done
45+
done
46+
47+
# copy project directory, they should only come from the project repo
48+
cp -RTf ${project_dir}/ ${TMPDIR}/
49+
50+
cd ${TMPDIR}
51+
52+
gem install bundle
53+
bundle install
54+
echo "baseurl: $READTHEDOCS_VERSION" > _config_rtd.yml
55+
cat _config_rtd.yml
56+
cat _config_theme.yml
57+
bundle exec jekyll build \
58+
--future \
59+
--config _config_rtd.yml,_config_theme.yml \
60+
--destination $READTHEDOCS_OUTPUT/html
61+
ls -Ra $READTHEDOCS_OUTPUT

0 commit comments

Comments
 (0)