jupyterlab / lumino

Lumino is a library for building interactive web applications
https://lumino.readthedocs.io/
Other
596 stars 127 forks source link

Automate link to ReadTheDocs PR preview #641

Open bollwyvl opened 9 months ago

bollwyvl commented 9 months ago

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.