Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

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

Example of a description edited with a link to Read the Docs preview

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.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-preview with the project-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)
  • single-version (optional): Set this to 'true' if your project is single version, so we can link to the correct URL. (default: 'false')