Skip to content

Commit 8e01c0e

Browse files
committed
Add PR preview feature
1 parent 0fc9945 commit 8e01c0e

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,41 @@ jobs:
189189
comment-author: 'github-actions[bot]'
190190
body-includes: '<!-- wp-playground-link -->'
191191

192+
- name: Build Playground URL
193+
if: steps.find-comment.outputs.comment-id == ''
194+
id: playground-url
195+
run: |
196+
PLUGIN_URL="https://github.com/${{ github.repository }}/archive/refs/heads/${{ github.head_ref }}.zip"
197+
198+
BLUEPRINT=$(cat <<'BLUEPRINT_EOF'
199+
{
200+
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
201+
"preferredVersions": { "php": "latest", "wp": "latest" },
202+
"siteOptions": { "blogname": "eXeLearning PR Test" },
203+
"steps": [
204+
{ "step": "setSiteLanguage", "language": "es_ES" },
205+
{
206+
"step": "installPlugin",
207+
"pluginData": { "resource": "url", "url": "PLUGIN_URL_PLACEHOLDER" },
208+
"options": { "activate": true }
209+
},
210+
{
211+
"step": "runPHP",
212+
"code": "<?php require_once '/wordpress/wp-load.php'; global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(true); ?>"
213+
}
214+
],
215+
"features": { "networking": true },
216+
"login": true,
217+
"landingPage": "/wp-admin/upload.php"
218+
}
219+
BLUEPRINT_EOF
220+
)
221+
222+
BLUEPRINT=$(echo "$BLUEPRINT" | sed "s|PLUGIN_URL_PLACEHOLDER|${PLUGIN_URL}|g")
223+
ENCODED=$(echo "$BLUEPRINT" | base64 -w 0)
224+
PLAYGROUND_URL="https://playground.wordpress.net/#${ENCODED}"
225+
echo "url=${PLAYGROUND_URL}" >> $GITHUB_OUTPUT
226+
192227
- name: Add Playground link comment
193228
if: steps.find-comment.outputs.comment-id == ''
194229
uses: peter-evans/create-or-update-comment@v4
@@ -198,8 +233,8 @@ jobs:
198233
<!-- wp-playground-link -->
199234
## Test in WordPress Playground
200235
201-
Test the **latest released version** of the plugin:
236+
Prueba el plugin **con el codigo de esta rama**:
202237
203-
**[Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/blueprint.json)**
238+
**[Abrir en WordPress Playground](${{ steps.playground-url.outputs.url }})**
204239
205-
> This link uses the latest published release, not the code from this PR branch.
240+
> El editor embebido de eXeLearning no esta disponible en esta preview (requiere build). El resto de funcionalidad del plugin (subida de ELP, shortcode, bloque Gutenberg, previsualizacion) si funciona.

0 commit comments

Comments
 (0)