Skip to content

Add handling to create playground links when creating zips for testing on a PR#1603

Merged
pattonwebz merged 3 commits intodevelopfrom
william/no-issue/add-playground-link-support-when-building-zips-on-prs
Apr 2, 2026
Merged

Add handling to create playground links when creating zips for testing on a PR#1603
pattonwebz merged 3 commits intodevelopfrom
william/no-issue/add-playground-link-support-when-building-zips-on-prs

Conversation

@pattonwebz
Copy link
Copy Markdown
Member

@pattonwebz pattonwebz commented Mar 31, 2026

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:

  • Added a step to resolve public plugin ZIP URLs, constructing direct download links for both the primary and reference plugin builds, depending on the event type (release or nightly). (.github/workflows/build-plugin-with-ref.yml)
  • Introduced a step that generates WordPress Playground URLs with the plugin preinstalled, using a Python script to encode the necessary blueprint and outputting these URLs as environment variables. (.github/workflows/build-plugin-with-ref.yml)

Workflow output improvements:

  • Updated the workflow summary output to include the generated Playground URLs for both primary and reference builds, or to indicate when these links are unavailable (e.g., for private repositories). (.github/workflows/build-plugin-with-ref.yml)
  • Enhanced the workflow's GitHub comment (posted after build completion) to include direct links to launch the Playground with the built plugin, improving discoverability and ease of testing for reviewers. (.github/workflows/build-plugin-with-ref.yml)

Checklist

  • PR is linked to the main issue in the repo
  • Tests are added that cover changes

Summary by CodeRabbit

  • Chores
    • CI now generates and exposes WordPress Playground links for the primary build and an optional reference build when available.
    • Pull request comments and build summaries include these Playground links, show "Not available" when a URL is missing, and report "Not built" when a reference build wasn't produced.

Copilot AI review requested due to automatic review settings March 31, 2026 17:32
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding handling to create playground links when building plugin ZIPs for PR testing, which is the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch william/no-issue/add-playground-link-support-when-building-zips-on-prs

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ab870e2 and 1064bad.

📒 Files selected for processing (1)
  • .github/workflows/build-plugin-with-ref.yml

Comment on lines +285 to +286
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 }}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

✅ Accessibility Checker build (primary only)

@github-actions github-actions bot removed the gha-build label Apr 2, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4317353 and 2b62b83.

📒 Files selected for processing (1)
  • .github/workflows/build-plugin-with-ref.yml

Comment on lines +263 to +276
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

@pattonwebz pattonwebz merged commit 560d978 into develop Apr 2, 2026
19 checks passed
@pattonwebz pattonwebz deleted the william/no-issue/add-playground-link-support-when-building-zips-on-prs branch April 2, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants