Skip to content

Generate static deployment for GH Pages#80

Merged
aganders3 merged 9 commits intomainfrom
static-deploy-gh-pages
Feb 27, 2026
Merged

Generate static deployment for GH Pages#80
aganders3 merged 9 commits intomainfrom
static-deploy-gh-pages

Conversation

@aganders3
Copy link
Copy Markdown
Collaborator

@aganders3 aganders3 commented Feb 12, 2026

This PR sets up a static API deployment via GitHub Pages alongside the existing Vercel/NextJS API. The Vercel API will remain in place to allow testing and grace period, and api.napari.org will continue to point to the Vercel deployment for the time being.

Changes

API Routes:

  • Renamed /api/conda/api/conda-map to avoid route conflict with /api/conda/{plugin_name}
  • Added rewrite in vercel.json so /api/conda still works (redirects to /api/conda-map)
  • Added deprecation headers to /api/conda endpoint:
    • Deprecation: true
    • Link: </api/conda-map>; rel="alternate"
    • X-Deprecated-Message explaining the change
    • I don't expect anyone to notice or care about this

Static Deployment:

  • Created scripts/prepare_gh_pages.py to generate static files from public/
    • Removes .json extensions to match API routes
    • Maps conda.jsonconda-map and index.jsonplugins
    • Nests everything under /api/ directory
    • Generates simple index.html homepage
  • Updated CI workflow (.github/workflows/update.yml):
    • Runs after committing public/ changes (doesn't interfere with existing process)
    • On PRs: Uploads gh-pages as downloadable artifact for inspection (host it locally with python -m http.server -d ./gh-pages)
    • On main/scheduled: Deploys to gh-pages branch via peaceiris/actions-gh-pages@v4

Known Limitations / Breaking Changes

When using the GitHub Pages API (not applicable to Vercel API):

  1. No name normalization - File paths are served as-is without package name normalization (known, accepted limitation previously discussed). To be clear: the names are already normalized. What this means is that clients will need to normalize names before making requests. Previously the Vercel API will accept non-normalized names, normalize them, and return the endpoint info (manifest, for example) for a plugin that matches the normalized name. Sorry I feel like I am not explaining this properly at midnight.

  2. Breaking change for /api/conda route - Moved to /api/conda-map to avoid conflict with /api/conda/{plugin_name}. The Vercel API maintains backward compatibility via rewrite, but the static API only serves /api/conda-map. This is a bummer, probably the biggest drawback here. TODO: update clients to use this new endpoint ASAP.

  3. Files are served as text/plain instead of application/json - GitHub Pages serves files without extension as text/plain. This generally doesn't matter:

  • Current Vercel API doesn't include a Content-Type header at all
  • Most API clients (like the plugin manager) don't care about content-type they will just try to parse what they get
  • Browsers will download files instead of displaying JSON when browsing directly to endpoints in Firefox or whatever, that's kind of a hassle but the hub is the human-readable version, and we could even make a little app that would show you the contents.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npe2api Ready Ready Preview, Comment Feb 12, 2026 4:35am

Copy link
Copy Markdown
Contributor

@DragaDoncila DragaDoncila left a comment

Choose a reason for hiding this comment

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

Honestly this all looks pretty simple and clean to me, I don't have many comments. Do we want to do anything before merge? @aganders3 I know you mentioned trying it with plugin manager possibly?

dest_paths.append(gh_pages_dir / "classifiers.json")
elif source_file == public_dir / "conda.json":
dest_paths.append(gh_pages_dir / "conda.json")
dest_paths.append(api_dir / "conda-map")
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.

so I notice sometimes we append the path with no .json to dest_paths as well as with the .json suffix. Can you explain why that is? I guess api_dir is the pages that are actually going to be served, and gh_pages_dir is like... backup files? Why do we put them in there at all?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's really an attempt to provide some backward-compatibility, but perhaps we don't need it. I think it's really an accident that both https://api.napari.org/conda.json and https://api.napari.org/api/conda point to the same thing in the current implementation.

@aganders3
Copy link
Copy Markdown
Collaborator Author

I tried it with the plugin manager and it worked, but I need to make sure I'm not missing any functionality. I think this is pretty safe to merge in its current form though, and that should keep the static version up to date with the next.js API.

@aganders3
Copy link
Copy Markdown
Collaborator Author

I'm going to merge and we can iterate as-needed, since having this live will allow us to do some more/better testing.

@aganders3 aganders3 merged commit d153034 into main Feb 27, 2026
5 checks passed
@aganders3 aganders3 deleted the static-deploy-gh-pages branch February 27, 2026 19:03
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