Skip to content

github/workflows: Deploy docs previews for pull requests.#19389

Open
mattytrentini wants to merge 1 commit into
micropython:masterfrom
mattytrentini:docs-pr-previews
Open

github/workflows: Deploy docs previews for pull requests.#19389
mattytrentini wants to merge 1 commit into
micropython:masterfrom
mattytrentini:docs-pr-previews

Conversation

@mattytrentini

Copy link
Copy Markdown
Contributor

Summary

Build the documentation for pull requests that touch docs/ or tests/cpydiff/ (not py/) and publish it to a separate repository (/micropython-docs-previews) served via GitHub Pages, under a per-PR directory (pr-<N>/). The preview link is posted as a comment on the PR, and the directory is removed when the PR is closed.

Previews live in a separate repository so this repository's history and clone size are never affected. The build runs under pull_request with a read-only token so untrusted fork code never gains write access; a separate workflow_run job performs the privileged publish using a repo-scoped SSH deploy key held in the PREVIEW_DEPLOY_KEY secret. If this is merged, I'll need some help setting this up in the micropython organization.

The PR number passed from the build is validated before use, and the deploy and cleanup jobs skip cleanly when PREVIEW_DEPLOY_KEY is not set, so the workflows are inert on forks and until a maintainer configures the previews repository.

Testing

I tested by merging this in my fork and then configuring a repo/token. Raising a dummy PR that modified docs published the docs to the repo. Removing the PR removed the published docs.

Trade-offs and Alternatives

I initially started by publishing to the micropython repository but this cost commits for each PR as it requires modifications to the gh_pages folder. Not ideal.

I also investigated using external services including Read the Docs and Cloudflare Pages. Both were possible but had tradeoffs; RtD had limits on the number of active branches supported and both meant using an external service with an account to manage.

We'll need to keep an eye on the size of the pages deployed, GitHub has a limit of ~1GB of gh_pages content. Each deployment of the docs consumes ~20MB so we'd need ~50 active PRs that modify docs to exceed the limit. Very unlikely. But worth keeping in mind if GitHub reduce the limit or if we have a spate of PRs.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

Build the documentation for pull requests that touch docs/ or
tests/cpydiff/ and publish it to a separate repository
(<owner>/micropython-docs-previews) served via GitHub Pages, under a
per-PR directory (pr-<N>/). The preview link is posted as a comment on
the PR, and the directory is removed when the PR is closed.

Previews live in a separate repository so this repository's history and
clone size are never affected. The build runs under pull_request with a
read-only token so untrusted fork code never gains write access; a
separate workflow_run job performs the privileged publish using a
repo-scoped SSH deploy key held in the PREVIEW_DEPLOY_KEY secret.

The PR number passed from the build is validated before use, and the
deploy and cleanup jobs skip cleanly when PREVIEW_DEPLOY_KEY is not set,
so the workflows are inert on forks and until a maintainer configures
the previews repository.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.51%. Comparing base (533a154) to head (8b52848).
⚠️ Report is 26 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19389   +/-   ##
=======================================
  Coverage   98.51%   98.51%           
=======================================
  Files         176      177    +1     
  Lines       22904    22927   +23     
=======================================
+ Hits        22563    22586   +23     
  Misses        341      341           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

Code size report:

Reference:  py/mpstate: Move mp_verbose_flag to MP_STATE_VM struct. [552fd21]
Comparison: github/workflows: Deploy docs previews for pull requests. [merge of 8b52848]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@Josverl

Josverl commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

I like the ability to quickly indpect the changes.

With the exclusion of thpy/ path, there will be some coy-diff doc changes that are missed when there are code only changes that affect these.
What was your rationale in changing that?

fi
- name: Download docs artifact
if: steps.config.outputs.enabled == 'true'
uses: actions/download-artifact@v4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current version is download-artifact@v8.0.1 and uses the current supported nodejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants