Skip to content

[Blueprints] Add a github:artifact resource type #1796

Open
@adamziel

Description

@adamziel

GitHub artifacts are difficult to use as Blueprint resources. As doubly zipped archives, they need convoluted peeling. Let's introduce a new resource type called github:artifact that would take handle the peeling for the developer.

What I want the Blueprint to look like

{
	"steps": [
		{
			step: 'installPlugin',
			pluginData: {
				resource: 'github:artifact',
				url: zipArtifactUrl
			},
		}
	]
}

What the Blueprint looks like today

{
	"steps": [
		{
			step: 'mkdir',
			path: '/wordpress/pr',
		},
		/*
		 * This is the most important step.
		 * It download the built plugin zip file exposed by GitHub CI.
		 *
		 * 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: '/wordpress/pr/pr.zip',
			data: {
				resource: 'url',
				url: zipArtifactUrl,
				caption: `Downloading Gutenberg PR ${prNumber}`,
			},
			progress: {
				weight: 2,
				caption: `Applying Gutenberg PR ${prNumber}`,
			},
		},
		/**
		 * GitHub CI artifacts are doubly zipped:
		 *
		 * pr.zip
		 *    gutenberg.zip
		 *       gutenberg.php
		 *       ... other files ...
		 *
		 * This step extracts the inner zip file so that we get
		 * access directly to gutenberg.zip and can use it to
		 * install the plugin.
		 */
		{
			step: 'unzip',
			zipPath: '/wordpress/pr/pr.zip',
			extractToPath: '/wordpress/pr',
		},
		{
			step: 'installPlugin',
			pluginData: {
				resource: 'vfs',
				path: '/wordpress/pr/gutenberg.zip',
			},
		}
	]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions