Add Nextcloud Playground preview with ready-to-use demo - #45
Conversation
Add `blueprint.json`, a GitHub workflow, and README section so the EPUB Viewer can be tried instantly in the browser via Nextcloud Playground (https://ateeducacion.github.io/nextcloud-playground/). - blueprint.json: installs `epubviewer` (pointing at canonical devnoname120/epubviewer for rewrite compatibility from forks), seeds a couple of sample EPUBs under Files, and lands on the Files view. - .github/workflows/playground-preview.yml: on push to master keeps a rolling `playground` release asset; on PRs builds the app, publishes a per-PR preview asset, rewrites the blueprint to target the PR zip via the CORS proxy, and posts a sticky "Preview this PR in the Nextcloud Playground" comment with a one-click link. Mirrors the pattern used in nextcloud-exelearning and the Moodle equivalent. - README.md: adds top badge + "Try in Nextcloud Playground" section documenting the zero-setup path and automatic PR previews. The static blueprint always targets the parent repository (devnoname120/epubviewer) so the URL-rewrite logic in the workflow (and future shared action) works correctly from forks and when this is later proposed upstream. See erseco/moodle-mod_questionnaire#1 for the equivalent Moodle change.
devnoname120
left a comment
There was a problem hiding this comment.
Maybe the solution would be to only have the button in the README.md and only run on the actual releases. There are barely any pull requests ever and no contributors basically, so it’s not very useful to have it run on PRs, etc.
Cool project either way!
| cp build/artifacts/epubviewer.zip epubviewer.zip | ||
|
|
||
| - name: Publish epubviewer.zip to the preview release | ||
| uses: softprops/action-gh-release@v2 |
There was a problem hiding this comment.
You should pin the hash of all the actions
There was a problem hiding this comment.
+ I don’t want to clutter my releases which pretty much vetoes the PR for me
| Automated Nextcloud Playground preview build (not a real release). | ||
| Installed in the browser via the blueprint `installApp` step. | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
I don’t want to have my GITHUB_TOKEN accessible anywhere in actions that run in PRs
|
|
||
| - name: Upsert PR comment | ||
| if: github.event_name == 'pull_request' | ||
| uses: actions/github-script@v7 |
| if: >- | ||
| github.event_name == 'push' || | ||
| (github.event.action != 'closed' && | ||
| github.event.pull_request.head.repo.full_name == github.repository) |
There was a problem hiding this comment.
That means that it will actually only run on my own PRs, which reduces the usefulness immensely.
| permissions: | ||
| contents: write | ||
| pull-requests: write |
There was a problem hiding this comment.
It’s scary to give the whole workflow (including the build, etc.) these permissions
|
Thanks for the feedback — you’re right. A workflow triggered from a fork would not have access to the repository’s secrets or its Please feel free to close/discard this PR. A simple Playground link or badge in the README is likely the better fit here. I’m a happy user of your excellent plugin and thought the Playground could be useful for people who want to try it without setting up Nextcloud locally. Thanks for taking the time to review the idea! |
|
@erseco Any ideas why the app doesn’t appear to be installed? |
|
Hi @devnoname120, I found the problem: In my tests I referenced my tests Nextcloud Playground now supports {
"step": "installApp",
"appId": "epubviewer",
"url": "https://github-proxy.exelearning.dev/?repo=devnoname120/epubviewer&release=latest&asset-pattern=epubviewer-*.tar.gz"
}
https://github.com/ateeducacion/nextcloud-playground/blob/main/scripts/zip-proxy-worker.js I use the same approach in other playground projects I maintain, including Moodle Playground, because browser-based playgrounds cannot reliably fetch GitHub release assets directly due to CORS restrictions. (all of these playgrounds are just to test the eXeLearning plugins, project from I'm contributor) WordPress Playground previously used the same kind of GitHub proxy approach, although they have since moved towards a different git-over-CORS solution. The only remaining change is updating |
|
@erseco I did the update. It works great now, thank you! |
About this PR — Nextcloud Playground
Nextcloud Playground runs a full Nextcloud in the browser (PHP + SQLite compiled to WebAssembly), provisioned from a declarative
blueprint.json. This PR wires theepubviewerapp into it so anyone can try the EPUB/PDF/CBR/CBZ viewer — and reviewers can test any future PR — in a live Nextcloud instance with zero local setup.Summary
epubviewer(theinstallAppURL points at the canonical parentdevnoname120/epubviewerso the rewrite logic works from forks), seeds a few sample EPUB files under Files, and lands on the Files view.playgroundrelease asset; on every PR builds the app (with Vite bundles), publishes a per-PRplayground-pr-Nasset through the CORS proxy, rewrites the blueprint to target the PR's zip, and posts a "Preview this PR in the Nextcloud Playground" button as a comment.All static references deliberately target the parent repository (
devnoname120/epubviewer) because the end goal is a clean contribution upstream.The implementation follows the exact pattern used for the Moodle equivalent and the approach already shipping in
nextcloud-exelearning.Test plan
epubviewerapp (log inadmin/admin).ℹ️ Live PR-preview demo: see the same change applied on my fork at erseco/epubviewer#1 — the workflow has already run there and posted the real "Preview this PR in the Nextcloud Playground" button.
Manual example of the button (as it appears in the fork PR)
Copy-pasted directly from the live comment on my fork PR:
This is exactly the button + link that the workflow will post on every future PR once this is merged.