ci: add preview release summary to GitHub Actions#941
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a GitHub Actions step summary and notification for the preview release workflow. The changes display package information and URLs generated by pkg-pr-new in the Actions summary tab and create a notice notification.
Changes:
- Added an
id: publishto the "Publish Preview" step to reference its outputs - Added a new "Preview summary" step that generates a formatted markdown summary showing SHA, packages, and URLs
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Publish Preview | ||
| id: publish | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: pnpx pkg-pr-new publish --pnpm ./packages/* |
There was a problem hiding this comment.
The "Publish Preview" step runs pkg-pr-new as a command-line tool with pnpx, but the code attempts to access step outputs (steps.publish.outputs.sha, steps.publish.outputs.packages, steps.publish.outputs.urls) as if it were a GitHub Action.
When running pkg-pr-new via pnpx, it does not automatically set GitHub Actions outputs. The step would need to explicitly capture the command output and set it using GitHub Actions output syntax (e.g., echo "sha=value" >> "$GITHUB_OUTPUT").
To fix this, you need to either:
- Use pkg-pr-new as a GitHub Action (uses: statement) instead of running it via pnpx
- Manually parse the command output and set the GitHub Actions outputs
| run: pnpx pkg-pr-new publish --pnpm ./packages/* | |
| uses: stackblitz-labs/pkg.pr.new@v1 | |
| with: | |
| pnpm: true | |
| packages: ./packages/* |
.github/workflows/preview.yml
Outdated
| { | ||
| echo "## pkg.pr.new preview" | ||
| echo "" | ||
| echo "**sha**: \`${{ steps.publish.outputs.sha }}\`" | ||
| echo "" | ||
| echo "### packages" | ||
| echo "" | ||
| for pkg in ${{ steps.publish.outputs.packages }}; do | ||
| echo "- \`$pkg\`" | ||
| done | ||
| echo "" | ||
| echo "### URLs" | ||
| echo "" | ||
| for url in ${{ steps.publish.outputs.urls }}; do | ||
| echo "- <$url>" | ||
| done | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| echo "::notice title=pkg.pr.new::sha=${{ steps.publish.outputs.sha }} (see Summary for packages/urls)" |
There was a problem hiding this comment.
The "Preview summary" step will fail if steps.publish.outputs.sha, steps.publish.outputs.packages, or steps.publish.outputs.urls are empty or undefined, since these expressions would expand to nothing and cause shell syntax errors or produce an incomplete summary.
Consider adding a check to ensure these outputs exist before using them, or set default values to handle cases where pkg-pr-new doesn't produce expected outputs.
| { | |
| echo "## pkg.pr.new preview" | |
| echo "" | |
| echo "**sha**: \`${{ steps.publish.outputs.sha }}\`" | |
| echo "" | |
| echo "### packages" | |
| echo "" | |
| for pkg in ${{ steps.publish.outputs.packages }}; do | |
| echo "- \`$pkg\`" | |
| done | |
| echo "" | |
| echo "### URLs" | |
| echo "" | |
| for url in ${{ steps.publish.outputs.urls }}; do | |
| echo "- <$url>" | |
| done | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| echo "::notice title=pkg.pr.new::sha=${{ steps.publish.outputs.sha }} (see Summary for packages/urls)" | |
| sha="${{ steps.publish.outputs.sha }}" | |
| packages="${{ steps.publish.outputs.packages }}" | |
| urls="${{ steps.publish.outputs.urls }}" | |
| { | |
| echo "## pkg.pr.new preview" | |
| echo "" | |
| echo "**sha**: \`${{ steps.publish.outputs.sha || 'N/A' }}\`" | |
| echo "" | |
| if [ -n "$packages" ]; then | |
| echo "### packages" | |
| echo "" | |
| for pkg in $packages; do | |
| echo "- \`$pkg\`" | |
| done | |
| echo "" | |
| fi | |
| if [ -n "$urls" ]; then | |
| echo "### URLs" | |
| echo "" | |
| for url in $urls; do | |
| echo "- <$url>" | |
| done | |
| fi | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| echo "::notice title=pkg.pr.new::sha=${{ steps.publish.outputs.sha || 'N/A' }} (see Summary for packages/urls)" |
.github/workflows/preview.yml
Outdated
| for pkg in ${{ steps.publish.outputs.packages }}; do | ||
| echo "- \`$pkg\`" | ||
| done | ||
| echo "" | ||
| echo "### URLs" | ||
| echo "" | ||
| for url in ${{ steps.publish.outputs.urls }}; do |
There was a problem hiding this comment.
The for loop syntax will not work correctly with GitHub Actions expressions. The expression ${{ steps.publish.outputs.packages }} will be evaluated before the shell script runs and expanded as a single string, but bash needs proper word splitting. If the output contains spaces or special characters, this could fail or produce unexpected results.
Consider using a different approach, such as:
- Using
jqto parse JSON output if pkg-pr-new provides JSON format - Reading from a file if the output is written to a file
- Using proper quoting and array handling in bash
The same issue applies to the URLs loop on lines 75-77.
| for pkg in ${{ steps.publish.outputs.packages }}; do | |
| echo "- \`$pkg\`" | |
| done | |
| echo "" | |
| echo "### URLs" | |
| echo "" | |
| for url in ${{ steps.publish.outputs.urls }}; do | |
| mapfile -t pkgs <<< '${{ steps.publish.outputs.packages }}' | |
| for pkg in "${pkgs[@]}"; do | |
| echo "- \`$pkg\`" | |
| done | |
| echo "" | |
| echo "### URLs" | |
| echo "" | |
| mapfile -t urls <<< '${{ steps.publish.outputs.urls }}' | |
| for url in "${urls[@]}"; do |
.github/workflows/preview.yml
Outdated
| for url in ${{ steps.publish.outputs.urls }}; do | ||
| echo "- <$url>" | ||
| done |
There was a problem hiding this comment.
The for loop syntax will not work correctly with GitHub Actions expressions. The expression ${{ steps.publish.outputs.urls }} will be evaluated before the shell script runs and expanded as a single string, but bash needs proper word splitting. If the output contains spaces or special characters, this could fail or produce unexpected results.
Consider using a different approach, such as:
- Using
jqto parse JSON output if pkg-pr-new provides JSON format - Reading from a file if the output is written to a file
- Using proper quoting and array handling in bash
ca6b48f to
bf4c7cd
Compare
Summary
show a summary for prerelease
Related Links
Checklist