Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate link to ReadTheDocs PR preview #641

Open
bollwyvl opened this issue Sep 28, 2023 · 0 comments
Open

Automate link to ReadTheDocs PR preview #641

bollwyvl opened this issue Sep 28, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bollwyvl
Copy link
Contributor

References

Problem

Finding the correct link to the ReadTheDocs preview is hidden inside the Checks UI, and attention is only drawn to it if it fails.

Proposed Solution

Add a workflow that posts a PR comment with a badge. Bonus: have the badge update with the status of the build.

Additional context

name: RTD Preview

on:
  pull_request_target:
    types: [opened]

permissions:
  pull-requests: write

jobs:
  binder:
    runs-on: ubuntu-latest
    steps:
      - name: Comment on the PR with the RTD preview
        uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            var PR_NUMBER = context.issue.number
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `[![readthedocs](NEED-A-BADGE.svg)](https://lumino--${PR_NUMBER}.org.readthedocs.build/en/${PR_NUMBER}) :point_left: Try it on ReadTheDocs`
            })

Ideally, there would be an RTD status badge for this specific PR, but this isn't supported yet. A sorta-ghetto approach would be to summon the logo, a la:

![the logo](https://lumino--633.org.readthedocs.build/en/633/_static/jupyter_logo.svg "the docs built once")

yielding the logo

This would be broken if the docs never built once, but then there would be little to distinguish it if a successive build broke it. But github caches all this stuff, so maybe it's not worth it if it ever looks broken when its not.

@bollwyvl bollwyvl added enhancement New feature or request status:Needs Triage labels Sep 28, 2023
@fcollonval fcollonval added good first issue Good for newcomers and removed status:Needs Triage labels Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants