{"id":17190913,"url":"https://github.com/dfm/rtds-action","last_synced_at":"2025-04-05T16:03:19.353Z","repository":{"id":44817136,"uuid":"281471253","full_name":"dfm/rtds-action","owner":"dfm","description":"Interface ReadTheDocs and GitHub Actions","archived":false,"fork":false,"pushed_at":"2025-02-14T23:49:19.000Z","size":245,"stargazers_count":48,"open_issues_count":7,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T15:02:38.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rtds-action.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-21T18:13:57.000Z","updated_at":"2025-03-26T07:20:17.000Z","dependencies_parsed_at":"2022-07-21T14:32:43.964Z","dependency_job_id":"8495e5ec-911c-4d4f-83e5-d87ba921d053","html_url":"https://github.com/dfm/rtds-action","commit_stats":{"total_commits":56,"total_committers":6,"mean_commits":9.333333333333334,"dds":0.1785714285714286,"last_synced_commit":"353a0c7373a8e4a205185c3934f5a4d04359c7ae"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfm%2Frtds-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfm%2Frtds-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfm%2Frtds-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfm%2Frtds-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfm","download_url":"https://codeload.github.com/dfm/rtds-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361593,"owners_count":20926641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T01:24:24.346Z","updated_at":"2025-04-05T16:03:19.330Z","avatar_url":"https://github.com/dfm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Interface Read the Docs and GitHub Actions\n\n[![Docs](https://github.com/dfm/rtds-action/workflows/Docs/badge.svg)](https://github.com/dfm/rtds-action/actions?query=workflow%3ADocs)\n[![Documentation Status](https://readthedocs.org/projects/rtds-action/badge/?version=latest)](https://rtds-action.readthedocs.io/en/latest/?badge=latest)\n\nI like to use [Read the Docs](https://readthedocs.org/) to build (and version!) my\ndocs, but I _also_ like to use [Jupyter notebooks](https://jupyter.org/) to\nwrite tutorials. Unfortunately, even though\n[notebooks can be executed on Read the Docs](https://docs.readthedocs.io/en/stable/guides/jupyter.html),\nsome of them take a very long time to run or\nneed special Docker environments to execute,\nwhich goes beyond what the platform supports. In these cases I needed to check\nexecuted notebooks (often with large images) into my git repository, causing\nhuge amounts of bloat. Futhermore, the executed notebooks would often get out of\nsync with the development of the code. **No more!!**\n\n_This library avoids these issues by executing code on [GitHub\nActions](https://github.com/features/actions), uploading build artifacts (in\nthis case, executed Jupter notebooks), and then (only then!) triggering a\nRead the Docs build that can download the executed notebooks._\n\nThere is still some work required to set up this workflow, but this library has\nthree pieces that make it a bit easier:\n\n1. A GitHub action that can be used to trigger a build for the current branch on\n   Read the Docs.\n2. A Sphinx extension that interfaces with the GitHub API to download the\n   artifact produced for the target commit hash.\n3. Some documentation that shows you how to set all this up!\n\n## Usage\n\nThe following gives the detailed steps of the process of setting up a project\nusing this workflow. But you can also see a fully functional example in this\nrepository. The documentation source is the `docs` directory and the\n`.github/workflows` directory includes a workflow that is executed to build the\ndocs using this package. The rendered page is available at\n[rtds-action.readthedocs.io](https://rtds-action.readthedocs.io).\n\n### 1. Set up Read the Docs\n\n1. First, you'll need to import your project as usual. If you've already done\n   that, don't worry: this will also work with existing Read the Docs projects.\n2. Next, go to the admin page for your project on Read the Docs, click on\n   `Integrations` (the URL is something like\n   `https://readthedocs.org/dashboard/YOUR_PROJECT_NAME/integrations/`).\n3. Click `Add integration` and select `Generic API incoming webhook`.\n4. Take note of the webhook `URL` and `token` on this page for use later.\n\nYou should also edit your webhook settings on GitHub by going to\n`https://github.com/USERNAME/REPONAME/settings/hooks` and clicking \"Edit\"\nnext to the Read the Docs hook. On that page, you should un-check the `Pushes`\noption.\n\n### 2. Set up GitHub Actions workflow\n\nIn this example, we'll assume that we have tutorials written as Jupyter\nnotebooks, saved as Python scripts using\n[Jupytext](https://jupytext.readthedocs.io/en/latest/introduction.html) (because\nthat's probably what you should be doing anyways!) in a directory called\n`docs/tutorials`.\n\nFirst, you'll need to add the Read the Docs webhook URL and token that you\nrecorded above as \"secrets\" for your GitHub project by going to the URL\n`https://github.com/USERNAME/REPONAME/settings/secrets`. I'll call them\n`RTDS_WEBHOOK_URL` (include the `https`!) and `RTDS_WEBHOOK_TOKEN` respectively.\n\nFor this use case, we can create the workflow `.github/workflows/docs.yml` as\nfollows:\n\n```yaml\nname: Docs\non: [push, release]\n\njobs:\n  notebooks:\n    name: \"Build the notebooks for the docs\"\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n\n      - name: Set up Python\n        uses: actions/setup-python@v2\n        with:\n          python-version: 3.8\n\n      - name: Install dependencies\n        run: |\n          python -m pip install -U pip\n          python -m pip install -r .github/workflows/requirements.txt\n\n      - name: Execute the notebooks\n        run: |\n          jupytext --to ipynb --execute docs/tutorials/*.py\n\n      - uses: actions/upload-artifact@v2\n        with:\n          name: notebooks-for-${{ github.sha }}\n          path: docs/tutorials\n\n      - name: Trigger RTDs build\n        uses: dfm/rtds-action@v1\n        with:\n          webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}\n          webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}\n          commit_ref: ${{ github.ref }}\n```\n\nHere, we're also assuming that we've added a `pip` requirements file at\n`.github/workflows/requirements.txt` with the dependencies required to execute\nthe notebooks. Also note that in the `upload-artifact` step we give our artifact\nthat depends on the hash of the current commit. This is crucial! We also need to\ntake note of the `notebooks-for-` prefix because we'll use that later.\n\nIt's worth emphasizing here that the only \"special\" steps in this workflow are\nthe last two. You can do whatever you want to generate your artifact in the\nprevious steps (for example, you could use `conda` instead of `pip`) because\nthis workflow is not picky about how you get there!\n\n### 3. Set up Sphinx\n\nFinally, you can edit the `conf.py` for your Sphinx documentation to add support\nfor fetching the artifact produced by your action. Here is a minimal example:\n\n```python\nimport os\n\nextensions = [... \"rtds_action\"]\n\n# The name of your GitHub repository\nrtds_action_github_repo = \"USERNAME/REPONAME\"\n\n# The path where the artifact should be extracted\n# Note: this is relative to the conf.py file!\nrtds_action_path = \"tutorials\"\n\n# The \"prefix\" used in the `upload-artifact` step of the action\nrtds_action_artifact_prefix = \"notebooks-for-\"\n\n# A GitHub personal access token is required, more info below\nrtds_action_github_token = os.environ[\"GITHUB_TOKEN\"]\n\n# Whether or not to raise an error on Read the Docs if the\n# artifact containing the notebooks can't be downloaded (optional)\nrtds_action_error_if_missing = False\n```\n\nWhere we have added the custom extension and set the required configuration\nparameters.\n\nYou'll need to provide Read the Docs with a GitHub personal access token (it only\nneeds the `public_repo` scope if your repo is public). You can generate a new\ntoken by going to [your GitHub settings\npage](https://github.com/settings/tokens). Then, save it as an environment\nvariable (called `GITHUB_TOKEN` in this case) on Read the Docs.\n\n## Development\n\nFor now, just a note: if you edit `src/js/index.js`, you _must_ run `npm run package` to generate the compiled action source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfm%2Frtds-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfm%2Frtds-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfm%2Frtds-action/lists"}