Add Read the Docs preview's link to Pull Requests

Overview

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.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 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)
Comments
  • Rename GitHub action

    Rename GitHub action

    I created the repository with readthedocs-preview, but that means that it is used as:

    steps:
      - uses: readthedocs/readthedocs-preview@main
    

    which repeats readthedocs. It is worth renaming it to something like:

    • preview-url
    • preview-links
    • documentation-links
    • pr-preview-links
    • ....
    opened by humitos 15
  • Update README

    Update README

    This is the content of the PR description.


    :books: Documentation preview :books:: https://another-slug--1.org.readthedocs.build/en/1/


    :books: Documentation preview :books:: https://readthedocs-preview--1.org.readthedocs.build/en/1/


    Extra content after the injected one. It should be intact after running it.

    opened by humitos 6
  • Change the verbose name of the action

    Change the verbose name of the action

    Multiple times now, I've surprised myself and tried to click the check for the PR docs links action in the PR list of checks. Apparently I'm confused by how prominent the check looks, but of course the "details" link for that check does not do what you expect.

    I'm actually not even sure where this name comes from, but just assuming its centrally configured here somehow.

    So, I would say this first check is more prominent that our own RTD build check:

    sorry, github is broken

    And even though our check has our icon in that list, I still somehow want to click the first check, the check for the links. So, if I am actively/subconsciously doing this as someone familiar with RTD, there must be others that would notice this.

    Looking more at this, "Read the Docs" looks more official than "docs/readthedocs.com:...", and the first link mentions "pull request preview". Though the links are in the PR description, users are probably still used to clicking the check detail links, so would be bound to hit this confusion.

    This is a case where showing this action in the PR action list is probably a worse scenario, but that's up to GitHub to deal with.

    But because we shouldn't expect users to interact with this particular action in the list of checks, I think a much less prominent name would at least not overwhelm our actual PR check.

    We could follow the naming scheme used in other checks, this is definitely less prominent and doesn't make me want to keep clicking it.

    great job github

    enhancement 
    opened by agjohnson 4
  • Incorrect link posted, maybe because my repo has a custom domain

    Incorrect link posted, maybe because my repo has a custom domain

    I just tried this out for the first time here:

    • https://github.com/simonw/sqlite-utils/pull/460

    The preview link it added didn't work, maybe because I have a custom domain setup?

    It linked to: https://readthedocs-preview--460.org.readthedocs.build/en/460/ - which 404s

    Here's the correct link: https://sqlite-utils--460.org.readthedocs.build/en/460/

    My docs are hosted at https://sqlite-utils.datasette.io/ using a custom subdomain setup like this: https://til.simonwillison.net/readthedocs/custom-subdomain

    opened by simonw 4
  • Support for more than one project

    Support for more than one project

    This is the case of our own repo https://github.com/readthedocs/readthedocs.org, where we have the docs and dev projects.

    Currently, using the action more than once will override the previous comment

    https://github.com/readthedocs/readthedocs-preview/blob/1029696f6a69477ff98e50ddb239e649f86ec384/action.yaml#L51

    We should make the comment easier to locate, instead of using a plain ---- as separator, we could use a comment as a delimiter of the start/end of the comment. For example:

    <!-- rtd-preview {project} start -->
    Content
    <!-- rtd-preview {project} end -->
    

    That way, the current "separator" would be part of the template itself

    ---
    :books: Documentation preview :books:: {docs-pr-index-url}
    
    opened by stsewd 3
  • Support Read the Docs Community & for Business

    Support Read the Docs Community & for Business

    Currently, the action only supports "Read the Docs Community". To support "Read for Business" we will need to think about:

    • the combination of the project's slug + organization's slug
    • the hard coded org.readthedocs.build domain

    Reference: https://github.com/readthedocs/readthedocs.org/pull/9450#discussion_r929260239

    opened by humitos 2
  • Add single_version config to fix URLs.

    Add single_version config to fix URLs.

    Fixes https://github.com/readthedocs/actions/issues/14


    :books: Documentation preview :books:: https://readthedocs-preview--16.org.readthedocs.build/en/16/

    opened by ericholscher 1
  • Support single version projects

    Support single version projects

    This should probably be hitting our API to get an unresolved URL for the project, but for now, an option that is single_version or similar would be good. It's breaking the links in the WTD builds because we have a single_version there.

    opened by ericholscher 1
  • Create a `v1` tag

    Create a `v1` tag

    Currently we are installing it from main, but that means that it could be breaking changes. We should tag v1, so people can start using it at this simple state without worrying about us changing the behavior.

    opened by humitos 1
  • Add comment only if there are changes under certain directory

    Add comment only if there are changes under certain directory

    It would be good to detect changes under certain directories (e.g. docs/) and only update the description in that situation. Example of a potential input for the action:

    file-path:
      description: "Path where to check for file modifications"
      default: "docs/"
      required: false
    

    Note we could use github.rest.pulls.listFiles to get the files changed in the PR:

    const {data: pull_files } = await github.rest.pulls.listFiles({
        owner: context.repo.owner,
        repo: context.repo.repo,
        pull_number: context.issue.number,
    });
    
    for (let file of pull_files) {
        // do something here
    }
    
    opened by humitos 1
  • Docs: mention the usage of `on.<>.paths`

    Docs: mention the usage of `on.<>.paths`

    Add this as a comment so people can see it and adapt to their needs.


    :books: Documentation preview :books:: https://readthedocs-preview--15.org.readthedocs.build/en/15/

    opened by humitos 0
  • Publish this action in the Marketplace

    Publish this action in the Marketplace

    After merging #16 and releasing a new v1 in #17; it would be good to publish this action in the GitHub Marketplace so people can find it easily. I don't have experience about how it works, but it would be good to research a little.

    https://docs.github.com/en/actions/creating-actions/publishing-actions-in-github-marketplace

    opened by humitos 0
  • Document how is the release process

    Document how is the release process

    Merging #16 will make us to do a release of the v1 again. We want to follow what we talked at https://github.com/readthedocs/actions/issues/5#issuecomment-1197688541

    This basically means re-tagging v1 to point to the latest commit that includes the single-version option.

    Since this release process is no the common for other repositories, we need to document it in a clear way, so it's easy to follow.

    documentation 
    opened by humitos 0
  • Edit PR's description or add a new comment

    Edit PR's description or add a new comment

    The action currently edits the PR description to add a separator and below that the links.

    Screenshot_2022-07-25_16-23-27

    It would be good if we can also support adding a new comment the first time and after that update the comment with the newer links, if any. Then, the user could choose the approach that like the most.

    Both approaches have pros/cons that is worth considering.

    opened by humitos 3
  • Insert URL to specific pages

    Insert URL to specific pages

    We could detect there were changes to specific files (via #3) and insert direct links to those documentation pages as well. For example, if the file docs/page/section.rst was modified, we could insert the link https://readthedocs-preview--1.org.readthedocs.build/en/1/pages/section.html

    There are some notes to mention:

    • we need to know where is the root directory that matches the root of the URL (in this case, we need to remove docs/ from the filename)
    • the URL is a pretty URL (/pages/section/ or /pages/section.html)
    • support user-configurable amount of links (with a small default), to avoid flooding in case of many files changed
    opened by humitos 8
Owner
Read the Docs
We host the world's documentation
Read the Docs
docs: Repository for OSS Docs

Kubeslice Documentation This project repository contains the documentation for Kubeslice. We are so glad that you want to contribute! Prerequisites To

kubeslice 26 Jan 3, 2023
Lets you add a character to Hacker News links to add social media and OpenGraph previews for sharing on things like Slack or Twitter.

news.ycombinator1.com Lets you add a character to Hacker News links to add social media and OpenGraph previews for sharing on things like Slack or Dis

Ian Langworth ☠ 38 Sep 18, 2022
Welcome contributers❤️🎉. Just add your name, Github profile link and Linkedin link🔗 Look at Readme for more.📖

Hello Welcome Developers! Step - 1 Create a GitHub account, if you don't already have one. Step - 2 Register for Hacktoberfest: Navigate to the Hackto

Prineth Fernando 28 Oct 31, 2022
Example CRUD API for API Fest'22. See Pull Requests for chapter 2 and 3

Example CRUD API for API Fest'22. See Pull Requests for chapter 2 and 3

Postman Student Program 6 Mar 2, 2022
Automate adding issues and pull requests to GitHub projects (beta)

actions/add-to-project Use this action to automatically add the current issue or pull request to a GitHub project. Note that this is for GitHub projec

GitHub Actions 293 Jan 3, 2023
Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu

Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu. More info in User Guide.

Oleksii Bilyk 5 Jul 31, 2022
🛠️ Easily track & compare gas costs estimated by Foundry on each of your Pull Requests!

?? ??️ Foundry Gas Diff Reporter Easily compare gas reports generated by Foundry automatically on each of your Pull Requests! How it works Everytime s

Romain Milon 133 Dec 28, 2022
🔐 Protect your Smart Contract Proxy from storage collisions upon upgrading, by running this action in a CI on each of your Pull Requests!

?? ??️ Foundry Storage Upgrade Seatbelt Protect your Smart Contract Proxy from storage collisions upon upgrading, by running this action in a CI on ea

Romain Milon 11 Dec 24, 2022
Use this as learning repo on how to create successful pull requests.

Hacktoberfest 2022 Special We will be posting a problem daily at 10 AM related to languages like HTML/CSS, Python, C++ till 30th Oct. No need to get i

null 24 Dec 22, 2022
Open! Inclusive! Collaborative! A community for enthusiasts exploring new technologies, working on innovative ideas and helping each other grow together. Open Issues, Raise ideas, Make Pull Requests!

About Us OplnCo previously known as Devstucom represents Open Inclusive Collaborative. We as a community help our fellow students build skills through

OpInCo Community 4 Oct 13, 2022
A file sharing service, where you can upload files and provide a download link for anyone on the internet by sharing the link 🔗 or via mail ✉️ which remains active for 24hours 🕙.

eShare | File Sharing App A file sharing service, where you can upload files and provide a download link for anyone on the internet by sharing the lin

Akhil Bhalerao 7 Nov 20, 2022
Read without losing the plot. Well Read helps you organize your notes about books you're reading, so you're never lost when starting a new volume.

Well Read Well Read is a website for tracking your reading of long book series. I made this to track how many pages I read in a session and to better

null 3 Dec 15, 2022
An online library for adding and removing a different number of books from a user collection, keeping track of the books you've read and the one's you are yet to read

Awesmoe Books A Website demo for our project of book store, The website has ability of adding and removing you books from yor library, Thats reflects

zieeco 11 Jul 8, 2022
MDN-Dark-Mode - Simple extension to add a dark mode with different themes to the MDN Web Docs website

MDN-Dark-Mode Information Chrome and Firefox extension that adds a dark mode wit

Santiago Galán Barlo 2 Mar 18, 2022
A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" ?? The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Linus Lee 20 Oct 30, 2022
The source code for the Discord Previews website.

discordpreviews.com The source code for the Discord Previews website. Setup Development Setup Install dependencies via npm install Use Docker Compose

Marvin Witt 12 Oct 26, 2022
Random Fractals stash of Observable Data Tools 🛠️ and Notebooks 📚 in ES Modules .js, .nb.json, .ojs, .omd, .html and .qmd document formats for Data Previews

Random Fractals stash of Observable Data Tools ??️ and Notebooks ?? in ES Modules .js, .nb.json, .ojs, .omd, .html and .qmd document formats for Data Previews in a browser and in VSCode IDE with Observable JS extension, Quarto extension, and new Quarto publishing tools.

Taras Novak 14 Nov 25, 2022
Cross-browser plugin to remove addictive features on YouTube like thumbnails, comments, previews and more...

ZenTube Installation Features Remove some (more) elements from Youtube to make it less addictive. Mix and match between the following options: Hide or

inversepolarity 57 Dec 17, 2022
A simple Todo app to add list of books a user has read using HTML, CSS, Webpack, JavaScript and modular architecture

Minimalist A simple Todo app to add list of books a user has read. It is implemented using HTML, CSS, Webpack, JavaScript and modular architecture. A

Elikplim 4 May 9, 2022