Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress PR Previewer: Simplify the Blueprint #1429

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 7 additions & 60 deletions packages/playground/website/public/wordpress.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
}

// Verify that the PR exists and that GitHub CI finished building it
const zipArtifactUrl = `/plugin-proxy.php?org=WordPress&repo=wordpress-develop&workflow=Test%20Build%20Processes&artifact=wordpress-build-${prNumber}&pr=${prNumber}`;
const zipArtifactUrl = `https://playground.wordpress.net/plugin-proxy.php?org=WordPress&repo=wordpress-develop&workflow=Test%20Build%20Processes&artifact=wordpress-build-${prNumber}&pr=${prNumber}`;
// Send the HEAD request to zipArtifactUrl to confirm the PR and the artifact both exist
const response = await fetch(zipArtifactUrl + '&verify_only=true');
if (response.status !== 200) {
Expand Down Expand Up @@ -216,65 +216,12 @@
const blueprint = {
$schema:
'https://playground.wordpress.net/blueprint-schema.json',
landingPage: urlParams.get('url') || '/wp-admin/',
steps: [
{
step: 'mkdir',
path: '/wordpress-new',
},
/*
* Download WordPress build from a given GitHub PR.
*
* Because the zip file is not publicly accessible, we use the
* plugin-proxy API endpoint to download it. The source code of
* that endpoint is available at:
* https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/website/public/plugin-proxy.php
*/
{
step: 'writeFile',
path: '/tmp/pr.zip',
data: {
resource: 'url',
url: zipArtifactUrl,
caption: `Downloading WordPress PR ${prNumber}`,
},
},
// Extract and remove the zip file.
{
step: 'unzip',
zipPath: '/tmp/pr.zip',
extractToPath: '/tmp',
},
{
step: 'rm',
path: '/tmp/pr.zip',
},
// Import the unzipped PR.
{
step: 'importWordPressFiles',
wordPressFilesZip: {
resource: 'vfs',
path: '/tmp/wordpress.zip',
},
pathInZip: '/build',
progress: {
weight: 20,
caption: `Applying WordPress PR ${prNumber}`,
},
},
{
step: 'runPHP',
code: `<?php
$_GET['step'] = 'upgrade_db';
require '/wordpress/wp-admin/upgrade.php';
`,
},
{
step: 'login',
username: 'admin',
password: 'password',
},
],
landingPage: urlParams.get('url') || '/wp-admin',
login: true,
preferredVersions: {
php: "7.4",
wp: zipArtifactUrl
}
};
const encoded = JSON.stringify(blueprint);

Expand Down
Loading