Add Read the Docs preview's link to Pull Requests
GitHub Action that automatically edits Pull Requests' descriptions with a link to documentation's preview on Read the Docs.
Example
How to use it
First, enable "Preview Documentation from Pull Requests" in your Read the Docs project by following this guide https://docs.readthedocs.io/en/latest/pull-requests.html
After that, create a GitHub Action in your repository with the following content:
# .github/workflows/documentation-links.yaml
name: Read the Docs Pull Request Preview
on:
pull_request_target:
types:
- opened
permissions:
pull-requests: write
jobs:
documentation-links:
runs-on: ubuntu-latest
steps:
- uses: readthedocs/readthedocs-preview@main
with:
project-slug: "readthedocs-preview"
Once you add this GitHub Action to your repository, next time anybody opens a Pull Request, the description will be edited to include the link to Read the Docs' documentation preview.
Note that you have to replace
readthedocs-preview
with theproject-slug
for your own project. You can find it in your Read the Docs' projects page in the right side of the page under "Project Slug".
Configuration
These are all the parameters this action supports:
project-slug
(required): Project's slug on Read the Docs. You can find it on your Read the Docs project's details page in the right menu under "Project Slug".project-language
(optional): Project's language code on Read the Docs. Example:en
for English,es
for Spanish, etc. (default:en
)message-template
(optional): Text message to be injected by the action in the Pull Request description. It supports the following placeholders to be replaced:{docs-pr-index-url}
: URL to the root of the documentation for the Pull Request preview.
platform
(optional): Read the Docs Community (community
) or Read the Docs for Business (business
). (default:community
)