GitHub Action that automatically edits Pull Requests' descriptions with a link to documentation's preview on Read the Docs.
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.yml
name: readthedocs/actions
on:
pull_request_target:
types:
- opened
# Execute this action only on PRs that touch
# documentation files.
# paths:
# - "docs/**"
permissions:
pull-requests: write
jobs:
documentation-links:
runs-on: ubuntu-latest
steps:
- uses: readthedocs/actions/preview@v1
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-previewwith theproject-slugfor your own project. You can find it in your Read the Docs' projects page in the right side of the page under "Project Slug".
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:enfor English,esfor 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)single-version(optional): Set this to'true'if your project is single version, so we can link to the correct URL. (default:'false')
