Add handling to create playground links when creating zips for testing on a PR#1603
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the plugin build GitHub Actions workflow by generating WordPress Playground launch links for the built ZIPs (when the repository is public), making it easier to test builds directly from workflow output and PR comments.
Changes:
- Resolves publicly accessible plugin ZIP URLs (release asset URLs or nightly.link artifact ZIP URLs) for primary and optional ref builds.
- Generates WordPress Playground URLs via an embedded Python blueprint encoder and exports them to subsequent steps.
- Surfaces Playground links in the PR comment (PR runs) and in the workflow summary output.
📝 Walkthrough🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/build-plugin-with-ref.yml:
- Around line 285-286: The exported environment variables PRIMARY_PLUGIN_ZIP_URL
and REF_PLUGIN_ZIP_URL are wrapped in single quotes which prevents GitHub
Actions expressions from expanding; update the export lines that reference
steps.playground-zips.outputs.primary_plugin_zip_url and
steps.playground-zips.outputs.ref_plugin_zip_url to use double quotes (or no
quotes) so the `${{ ... }}` expressions are evaluated by GitHub Actions and the
variables receive the actual URLs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 01312e4f-dcc9-4b8b-98b5-99b58f7ec43e
📒 Files selected for processing (1)
.github/workflows/build-plugin-with-ref.yml
| export PRIMARY_PLUGIN_ZIP_URL='${{ steps.playground-zips.outputs.primary_plugin_zip_url }}' | ||
| export REF_PLUGIN_ZIP_URL='${{ steps.playground-zips.outputs.ref_plugin_zip_url }}' |
There was a problem hiding this comment.
Single quotes prevent GitHub expression expansion.
Using single quotes around ${{ ... }} in shell prevents the expression from being evaluated by GitHub Actions. The variables PRIMARY_PLUGIN_ZIP_URL and REF_PLUGIN_ZIP_URL will contain the literal strings ${{ steps.playground-zips.outputs.primary_plugin_zip_url }} instead of the actual URLs.
🐛 Proposed fix
- export PRIMARY_PLUGIN_ZIP_URL='${{ steps.playground-zips.outputs.primary_plugin_zip_url }}'
- export REF_PLUGIN_ZIP_URL='${{ steps.playground-zips.outputs.ref_plugin_zip_url }}'
+ export PRIMARY_PLUGIN_ZIP_URL="${{ steps.playground-zips.outputs.primary_plugin_zip_url }}"
+ export REF_PLUGIN_ZIP_URL="${{ steps.playground-zips.outputs.ref_plugin_zip_url }}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/build-plugin-with-ref.yml around lines 285 - 286, The
exported environment variables PRIMARY_PLUGIN_ZIP_URL and REF_PLUGIN_ZIP_URL are
wrapped in single quotes which prevents GitHub Actions expressions from
expanding; update the export lines that reference
steps.playground-zips.outputs.primary_plugin_zip_url and
steps.playground-zips.outputs.ref_plugin_zip_url to use double quotes (or no
quotes) so the `${{ ... }}` expressions are evaluated by GitHub Actions and the
variables receive the actual URLs.
|
✅ Accessibility Checker build (primary only)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/build-plugin-with-ref.yml:
- Around line 263-276: The generated plugin ZIP URLs use raw file-name variables
(PRIMARY_ZIP_NAME, PRIMARY_ZIP_NAME_NO_EXT, REF_ZIP_NAME, REF_ZIP_NAME_NO_EXT)
which can contain spaces or reserved characters; percent-encode those path
segments before constructing PRIMARY_PLUGIN_ZIP_URL and REF_PLUGIN_ZIP_URL.
Modify the script to URL-encode the ZIP name variables (the ones used in the
nightly.link and GitHub releases paths) using a safe shell encoding helper
(e.g., call a small python/node/printf+jq snippet to percent-encode) and then
use the encoded variables when assigning PRIMARY_PLUGIN_ZIP_URL and
REF_PLUGIN_ZIP_URL. Ensure both release and nightly.link branches use the
encoded names.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e0ec74bb-2f8a-4172-b65e-513b316ba772
📒 Files selected for processing (1)
.github/workflows/build-plugin-with-ref.yml
| if [ -n "${PRIMARY_ZIP_NAME:-}" ]; then | ||
| if [ "${{ github.event_name }}" = "release" ]; then | ||
| PRIMARY_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/${PRIMARY_ZIP_NAME}" | ||
| else | ||
| PRIMARY_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/${PRIMARY_ZIP_NAME_NO_EXT}.zip" | ||
| fi | ||
| fi | ||
|
|
||
| if [ "${{ steps.check_ref.outputs.need_ref_build }}" = "true" ] && [ -n "${REF_ZIP_NAME:-}" ]; then | ||
| if [ "${{ github.event_name }}" = "release" ]; then | ||
| REF_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/${REF_ZIP_NAME}" | ||
| else | ||
| REF_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/${REF_ZIP_NAME_NO_EXT}.zip" | ||
| fi |
There was a problem hiding this comment.
URL path segments should be percent-encoded before building public ZIP links.
If ZIP names contain spaces or reserved characters (possible with custom ref input), generated Playground URLs can be invalid/broken.
💡 Proposed fix
- name: Resolve public plugin URLs for Playground
id: playground-zips
if: github.event.repository.private == false
run: |
+ urlencode() {
+ python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$1"
+ }
+
PRIMARY_PLUGIN_ZIP_URL=""
REF_PLUGIN_ZIP_URL=""
if [ -n "${PRIMARY_ZIP_NAME:-}" ]; then
if [ "${{ github.event_name }}" = "release" ]; then
- PRIMARY_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/${PRIMARY_ZIP_NAME}"
+ PRIMARY_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/$(urlencode "$PRIMARY_ZIP_NAME")"
else
- PRIMARY_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/${PRIMARY_ZIP_NAME_NO_EXT}.zip"
+ PRIMARY_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/$(urlencode "$PRIMARY_ZIP_NAME_NO_EXT").zip"
fi
fi
if [ "${{ steps.check_ref.outputs.need_ref_build }}" = "true" ] && [ -n "${REF_ZIP_NAME:-}" ]; then
if [ "${{ github.event_name }}" = "release" ]; then
- REF_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/${REF_ZIP_NAME}"
+ REF_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/$(urlencode "$REF_ZIP_NAME")"
else
- REF_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/${REF_ZIP_NAME_NO_EXT}.zip"
+ REF_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/$(urlencode "$REF_ZIP_NAME_NO_EXT").zip"
fi
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [ -n "${PRIMARY_ZIP_NAME:-}" ]; then | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| PRIMARY_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/${PRIMARY_ZIP_NAME}" | |
| else | |
| PRIMARY_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/${PRIMARY_ZIP_NAME_NO_EXT}.zip" | |
| fi | |
| fi | |
| if [ "${{ steps.check_ref.outputs.need_ref_build }}" = "true" ] && [ -n "${REF_ZIP_NAME:-}" ]; then | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| REF_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/${REF_ZIP_NAME}" | |
| else | |
| REF_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/${REF_ZIP_NAME_NO_EXT}.zip" | |
| fi | |
| if [ -n "${PRIMARY_ZIP_NAME:-}" ]; then | |
| urlencode() { | |
| python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$1" | |
| } | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| PRIMARY_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/$(urlencode "$PRIMARY_ZIP_NAME")" | |
| else | |
| PRIMARY_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/$(urlencode "$PRIMARY_ZIP_NAME_NO_EXT").zip" | |
| fi | |
| fi | |
| if [ "${{ steps.check_ref.outputs.need_ref_build }}" = "true" ] && [ -n "${REF_ZIP_NAME:-}" ]; then | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| REF_PLUGIN_ZIP_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ github.event.release.tag_name }}/$(urlencode "$REF_ZIP_NAME")" | |
| else | |
| REF_PLUGIN_ZIP_URL="https://nightly.link/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/$(urlencode "$REF_ZIP_NAME_NO_EXT").zip" | |
| fi |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/build-plugin-with-ref.yml around lines 263 - 276, The
generated plugin ZIP URLs use raw file-name variables (PRIMARY_ZIP_NAME,
PRIMARY_ZIP_NAME_NO_EXT, REF_ZIP_NAME, REF_ZIP_NAME_NO_EXT) which can contain
spaces or reserved characters; percent-encode those path segments before
constructing PRIMARY_PLUGIN_ZIP_URL and REF_PLUGIN_ZIP_URL. Modify the script to
URL-encode the ZIP name variables (the ones used in the nightly.link and GitHub
releases paths) using a safe shell encoding helper (e.g., call a small
python/node/printf+jq snippet to percent-encode) and then use the encoded
variables when assigning PRIMARY_PLUGIN_ZIP_URL and REF_PLUGIN_ZIP_URL. Ensure
both release and nightly.link branches use the encoded names.
This pull request enhances the GitHub Actions workflow for building the plugin by adding automated support for generating and sharing WordPress Playground links. These links allow users to quickly test the built plugin in a live environment, streamlining the review and testing process. The new functionality is only enabled for public repositories and when plugin ZIP URLs are available.
Key changes include:
WordPress Playground integration:
Workflow output improvements:
Checklist
Summary by CodeRabbit