Skip to content

Commit d564e7f

Browse files
committed
Use RTD for pull request previews
1 parent 197a955 commit d564e7f

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

.github/workflows/rtd-pr-preview.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# .github/workflows/rtd-pr-preview.yml
2+
name: readthedocs/actions
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
# Execute this action only on PRs that touch
8+
# documentation files.
9+
# paths:
10+
# - "docs/**"
11+
12+
permissions:
13+
pull-requests: write
14+
15+
jobs:
16+
documentation-links:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: readthedocs/actions/preview@v1
20+
with:
21+
project-slug: "plone6"
22+
single-version: "true"

.readthedocs.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.12"
13+
commands:
14+
# Cancel building pull requests when there aren't changes in the docs directory or YAML file.
15+
# You can add any other files or directories that you'd like here as well,
16+
# like your docs requirements file, or other files that will change your docs build.
17+
#
18+
# If there are no changes (git diff exits with 0) we force the command to return with 183.
19+
# This is a special exit code on Read the Docs that will cancel the build immediately.
20+
- |
21+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/ .readthedocs.yaml requirements-initial.txt requirements.txt;
22+
then
23+
exit 183;
24+
fi
25+
- make rtd-pr-preview

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,17 @@ livehtml: deps ## Rebuild Sphinx documentation on changes, with live-reload in
224224
--port 8050 \
225225
-b html . "$(BUILDDIR)/html" $(SPHINXOPTS) $(O)
226226

227-
.PHONY: netlify
228-
netlify:
227+
.PHONY: rtd-pr-preview
228+
rtd-pr-preview: ## Build pull request preview on Read the Docs
229229
pip install -r requirements-initial.txt
230230
pip install -r requirements.txt
231-
pip install -r requirements-netlify.txt
232-
git submodule init; \
233-
git submodule update; \
234-
pip install -e submodules/plone.api[test]; \
231+
git submodule init
232+
git submodule update
233+
pip install -e submodules/plone.api[test]
235234
ln -s ../submodules/volto/docs/source ./docs/volto
236235
ln -s ../submodules/plone.restapi ./docs/plone.restapi
237236
ln -s ../submodules/plone.api/docs ./docs/plone.api
238-
cd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html && cp ./netlify_robots.txt $(BUILDDIR)/html/robots.txt
237+
cd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/
239238

240239
.PHONY: storybook
241240
storybook:

0 commit comments

Comments
 (0)