Skip to content

Commit 0910d94

Browse files
committed
Polish README onboarding flow
1 parent ef084f0 commit 0910d94

1 file changed

Lines changed: 75 additions & 2 deletions

File tree

README.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ Start with **[Quick start](#quick-start)** and choose the path that matches your
2626
## Table of contents
2727

2828
- [Quick start](#quick-start)
29+
- [Which setup should I use?](#which-setup-should-i-use)
2930
- [No build step](#no-build-step)
3031
- [With a build step](#with-a-build-step)
3132
- [See it live](#see-it-live)
3233
- [Recipes](#recipes)
34+
- [Using an LLM to add this to your repository](#using-an-llm-to-add-this-to-your-repository)
3335
- [How it works](#how-it-works)
3436
- [Reference](#reference)
3537
- [Limitations & gotchas](#limitations--gotchas)
@@ -42,6 +44,18 @@ Start with **[Quick start](#quick-start)** and choose the path that matches your
4244

4345
## Quick start
4446

47+
### Which setup should I use?
48+
49+
| Your repository | Use this setup |
50+
|---|---|
51+
| A plugin or theme works directly from the repository checkout | [No build step](#no-build-step) |
52+
| A plugin or theme needs Composer, npm, Vite, or another build command first | [With a build step](#with-a-build-step) |
53+
| You accept public fork PRs and need previews to work for those contributors | [With a build step](#with-a-build-step) |
54+
| A preview should install multiple built plugins or themes | Start with [With a build step](#with-a-build-step), then use the [monorepo recipe](#monorepo-with-multiple-plugins-all-activated-together) |
55+
| The repository is private | The default setup is not enough; Playground needs public, unauthenticated URLs. See [Limitations & gotchas](#limitations--gotchas). |
56+
57+
If you are not sure, start with **No build step** only when the files committed to the pull request are exactly the files WordPress should run. If CI must generate anything first, use **With a build step**.
58+
4559
### No build step
4660

4761
Use this setup when your plugin or theme can run directly from the repository, with no Composer install, npm build, or asset pipeline. Create one workflow file:
@@ -66,10 +80,18 @@ jobs:
6680
github-token: ${{ secrets.GITHUB_TOKEN }}
6781
```
6882
83+
You do not need to create `secrets.GITHUB_TOKEN`; GitHub provides it automatically. The `permissions` block gives that token the access this action needs.
84+
6985
Open a pull request. The action adds a Preview button to the pull request description. When someone clicks it, Playground fetches the plugin or theme from GitHub and boots WordPress with it activated.
7086

7187
This direct setup does not run a build command or publish a ZIP artifact; Playground loads the files from GitHub at the pull request ref.
7288

89+
Expected result:
90+
91+
- The PR workflow finishes successfully.
92+
- The PR description contains a managed Preview button block.
93+
- Clicking the button opens Playground with your plugin or theme installed and activated.
94+
7395
> **Fork PR note:** this direct one-workflow setup is simplest for same-repository PRs. Public fork PRs usually receive a read-only `GITHUB_TOKEN`, so the action may be unable to edit the PR description. If fork contributors need working previews, use the two-workflow build/publish setup below even when the build command is just a small zip step.
7496

7597
### With a build step
@@ -94,6 +116,8 @@ jobs:
94116
npm run build:plugin-zip
95117
```
96118

119+
In `artifacts: my-plugin=build/my-plugin.zip`, `my-plugin` is the artifact name and `build/my-plugin.zip` is the ZIP file your `build-command` must create. The ZIP should extract to a plugin slug folder, for example `my-plugin/my-plugin.php`, not just files at the ZIP root. See [Plugin zips must extract to a slug-named folder](#limitations--gotchas) if your preview opens but the plugin is missing.
120+
97121
```yaml
98122
# .github/workflows/pr-preview-publish.yml
99123
name: PR Preview - Publish
@@ -116,8 +140,18 @@ jobs:
116140
kind: plugin # or: kind: theme
117141
```
118142

143+
`kind: plugin` tells the publish workflow to generate the simplest Blueprint for one plugin ZIP: install it and activate it. Use `kind: theme` for one theme ZIP. For multiple ZIPs or extra setup steps, use a custom `blueprint:` recipe below.
144+
145+
You do not need to create `secrets.GITHUB_TOKEN`; GitHub provides it automatically to each workflow run.
146+
119147
Open a pull request. The build workflow runs `npm ci && npm run build:plugin-zip`. After that succeeds, the publish workflow uploads the resulting ZIP to a public release URL and posts the Preview button. When someone clicks it, Playground installs and activates the built plugin.
120148

149+
Expected result:
150+
151+
- The build workflow uploads a `wp-playground-preview-pr<N>-<SHA>` artifact.
152+
- The publish workflow creates or updates a `ci-artifacts` prerelease and uploads the built ZIP there.
153+
- The PR description contains a Preview button that opens Playground with the built plugin or theme installed.
154+
121155
> **Why two workflow files?** The build workflow runs untrusted pull request code with read-only permissions. The publish workflow runs later, from the trusted default-branch workflow, with the write permissions needed to upload release assets and update the pull request. See [How it works](#how-it-works).
122156

123157
---
@@ -139,7 +173,7 @@ Each link is a real, public repo running these workflows. Each PR has a working
139173

140174
Pick the recipe that matches your repository, then adjust the paths, commands, and artifact names for your project.
141175

142-
Unless a recipe shows a full workflow file, the YAML snippet is a step that goes under `jobs.preview.steps` in the [no-build workflow](#no-build-step).
176+
Unless a recipe shows a full workflow file, the YAML snippet is a replacement step under `jobs.preview.steps` in the [no-build workflow](#no-build-step).
143177

144178
### Plugin in a subdirectory
145179

@@ -154,6 +188,8 @@ In `.github/workflows/pr-preview.yml`, replace the Quick start step under `jobs.
154188

155189
### Theme
156190

191+
In `.github/workflows/pr-preview.yml`, replace the Quick start step under `jobs.preview.steps` with:
192+
157193
```yaml
158194
- uses: WordPress/action-wp-playground-pr-preview@v3
159195
with:
@@ -163,6 +199,8 @@ In `.github/workflows/pr-preview.yml`, replace the Quick start step under `jobs.
163199

164200
### Plugin **and** theme together
165201

202+
Use this when a PR should preview a plugin and a theme from the same repository. In `.github/workflows/pr-preview.yml`, replace the Quick start step under `jobs.preview.steps` with:
203+
166204
```yaml
167205
- uses: WordPress/action-wp-playground-pr-preview@v3
168206
with:
@@ -211,9 +249,17 @@ Or host the blueprint elsewhere and pass the URL:
211249

212250
Learn more about Blueprints: <https://wordpress.github.io/wordpress-playground/blueprints/>.
213251

252+
Choose the Blueprint input based on where the JSON comes from:
253+
254+
- Use `blueprint` when the workflow can include the full JSON string.
255+
- Use `blueprint-url` when the JSON is already hosted at a public URL.
256+
- Use `blueprint-from-artifact` when the build workflow generates `blueprint.json` dynamically.
257+
214258
### Single plugin with a build step
215259

216-
See the [Quick start with a build step](#with-a-build-step) above. The reusable workflow handles checkout, optional Node/PHP setup, build, zip, upload, public URL, blueprint, and button posting.
260+
See the [Quick start with a build step](#with-a-build-step) above. The reusable workflow handles checkout, optional Node/PHP setup, build, ZIP upload, public URL, Blueprint generation, and button posting.
261+
262+
The most common mistake is producing a ZIP with the wrong shape. WordPress plugin ZIPs should extract to a slug-named folder, such as `my-plugin/my-plugin.php`. If your build command runs `zip -r my-plugin.zip .` from inside the plugin directory, stage the files into a folder first, then zip that folder.
217263

218264
### Monorepo with multiple plugins, all activated together
219265

@@ -471,6 +517,33 @@ Available template variables are listed under [Reference → Template variables]
471517
472518
---
473519
520+
## Using an LLM to add this to your repository
521+
522+
If you ask an LLM or coding agent to set this up, give it enough context to choose the right path instead of blindly pasting the first YAML snippet.
523+
524+
Suggested prompt:
525+
526+
```text
527+
Add WordPress/action-wp-playground-pr-preview@v3 to this repository.
528+
First inspect whether the WordPress plugin or theme can run directly from the repository checkout, or whether CI must build files first.
529+
If no build step is needed, add one pull_request workflow using plugin-path or theme-path.
530+
If a build step is needed, add the two-workflow preview-build.yml / preview-publish.yml setup.
531+
Use the smallest working configuration. Preserve existing CI. Do not use pull_request_target.
532+
After editing, verify that any artifacts path listed in artifacts: is actually created by build-command.
533+
```
534+
535+
Checklist for reviewing the LLM's output:
536+
537+
- `secrets.GITHUB_TOKEN` is referenced but not created manually.
538+
- Direct action usage appears under `jobs.<job_id>.steps[].uses`.
539+
- Reusable workflow usage appears under `jobs.<job_id>.uses`.
540+
- Build and publish workflows use the same version, for example `@v3`.
541+
- Every `artifacts` entry has the form `name=path/to/file.zip`, and the build command creates that exact ZIP path.
542+
- Plugin ZIPs extract to a slug-named folder, not directly to files at the ZIP root.
543+
- The workflow does not use `pull_request_target`.
544+
545+
---
546+
474547
## How it works
475548

476549
### Mental model

0 commit comments

Comments
 (0)