Open adamziel opened 7 months ago
In the github-proxy section, did you mean "https://github-proxy.com" instead of "https://github.com/topics/https-proxy" Not sure if the original links were intentional.
Use GitHub Proxy GitHub Proxy solves the ZIP file problem, too. You can use it to download zipped directories and branches from your public repo. See https://github-proxy.com for more details. From there, you'd create a Blueprint
I will also write some additional documentation for it, as well as address some issues
Relevant PR to add a preview for the Automattic/themes repo from @vcanales: https://github.com/Automattic/themes/pull/7719. Also, this setup is used by the Blueprints community space repo – it updates the preview comment as the PR is updated and merged.
Not sure if the original links were intentional.
@stoph just a typo, I was moving too fast :-)
I want to work on this one
A new draft for the intro:
The intro should be used to establish the following:
This is a kindness to the reader that should help them bail early if the tutorial is not for them and they can't decide from the title. It also introduces the vocabulary (especially with third-party items), which helps them follow the tutorial fluently.
[describe the problem]
This article assumes you have a GitHub repository where active development happens and that you want to preview changes in each PR. Playground is an excellent tool for quickly opening a new WordPress instance in your browser with one click. However, setting up a custom preview (a specific theme, plugin, or combination) takes a bit more than a click. Setting it up for each PR can add up to time and involve a lot of repetition.
[describe the outcome]
In combination with other tools, available at GitHub, many actions can be automated. This is a tutorial on how to automate creating a comment that contains a Playground preview link to a WordPress instance with all the changes from the current PR.
This functionality is utilized in the wordpress-develop repository's workflow. A CI action comments on every Pull Request with a Playground preview link.
[list the requirements and expected knowledge]
Prerequisites:
This tutorial will mention a few things outside of WordPress. Understanding them profoundly is not necessary, but a basic understanding of what they do in general will help in following the tutorial and successfully completing it.
Good to understand:
Hello @zzap
currently, the text gave me the feeling, that I will just need to grab the CI action from one of the mentioned repos, but the important is missing (to me), the adaption process, like @adamziel pointed out earlier.
If you do want to add some information on that, I'll happily share some of my good and bad adaption-experiences.
This is a very rough draft of a new documentation page. Let's turn it into a PR and refine it before shipping. CC @ockham @ironprogrammer @stoph
Done is
packages/docs/site/docs/02-start-using/04-how-to-add-pull-requests-previews-to-your-repository.md
Related resources
Draft below:
Using Playground PR Preview Comments
Playground offers a built-in functionality for creating previews directly from pull requests. This functionality is utilized in the
wordpress-develop
repository's workflow (https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/). A CI action comments on every Pull Request with a Playground preview link:Preparing a GitHub CI action
Adapt this wordpress-develop workflow to your repository. If you're not sure how, get familiar with GitHub actions first.
Preparing a Zip file for the preview
Loading a Pull Request in WordPress Playground requires exposing a
.zip
file with a WordPress-installable artifact (a theme, a plugin, an entire site, etc.).There's a few ways you can expose that zip:
Include it in the PR
While less ideal, the built zip artifact file can be directly included within the pull request itself. From there, you could reference it from https://raw.githubusercontent.com/.
Upload to GitHub Artifacts
This approach mirrors the method used in
wordpress-develop
previews. It leverages the/plugin-proxy.php
endpoint to bypass GitHub authentication and CORS.To get it running, you'd need to:
Use github-proxy.com
https://github.com/stoph/github-proxy solves the ZIP file problem, too. You can use it to download zipped directories and branches from your public repo. See https://github.com/stoph/github-proxy/issues for more details. From there, you'd create a Blueprint:
Gotchas
If a user without permissions in the repo submits a PR via a fork, the action always failed with an error such as:
The solution is to use a
pull_request_target
trigger for the workflow instead ofpull_request
. Example: See how this Blueprints PR has a preview link even though it comes from a fork. The workflow in the Blueprints Gallery repo runs on pull_request_target