Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 32 additions & 72 deletions scripts/cicd/pr-storybook-deploy-and-comment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,50 +120,9 @@ post_comment() {

# Main execution
if [ "$STATUS" = "starting" ]; then
# Check if this is a version-bump branch
IS_VERSION_BUMP="false"
if echo "$BRANCH_NAME" | grep -q "^version-bump-"; then
IS_VERSION_BUMP="true"
fi

# Post starting comment with appropriate message
if [ "$IS_VERSION_BUMP" = "true" ]; then
comment=$(cat <<EOF
$COMMENT_MARKER
## 🎨 Storybook Build Status

<img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> **Build is starting...**

⏰ Started at: $START_TIME UTC

### πŸš€ Building Storybook
- πŸ“¦ Installing dependencies...
- πŸ”§ Building Storybook components...
- 🎨 Running Chromatic visual tests...

---
⏱️ Please wait while the Storybook build is in progress...
EOF
)
else
comment=$(cat <<EOF
$COMMENT_MARKER
## 🎨 Storybook Build Status

<img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> **Build is starting...**

⏰ Started at: $START_TIME UTC

### πŸš€ Building Storybook
- πŸ“¦ Installing dependencies...
- πŸ”§ Building Storybook components...
- 🌐 Preparing deployment to Cloudflare Pages...

---
⏱️ Please wait while the Storybook build is in progress...
EOF
)
fi
# Post starting comment
comment="$COMMENT_MARKER
## 🎨 Storybook: <img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> Building..."
post_comment "$comment"

elif [ "$STATUS" = "completed" ]; then
Expand Down Expand Up @@ -192,56 +151,57 @@ elif [ "$STATUS" = "completed" ]; then
WORKFLOW_CONCLUSION="${WORKFLOW_CONCLUSION:-success}"
WORKFLOW_URL="${WORKFLOW_URL:-}"

# Generate completion comment based on conclusion
# Generate compact header based on conclusion
if [ "$WORKFLOW_CONCLUSION" = "success" ]; then
status_icon="βœ…"
status_text="Build completed successfully!"
footer_text="πŸŽ‰ Your Storybook is ready for review!"
status_text="Built"
elif [ "$WORKFLOW_CONCLUSION" = "skipped" ]; then
status_icon="⏭️"
status_text="Build skipped."
footer_text="ℹ️ Chromatic was skipped for this PR."
status_text="Skipped"
elif [ "$WORKFLOW_CONCLUSION" = "cancelled" ]; then
status_icon="🚫"
status_text="Build cancelled."
footer_text="ℹ️ The Chromatic run was cancelled."
status_text="Cancelled"
else
status_icon="❌"
status_text="Build failed!"
footer_text="⚠️ Please check the workflow logs for error details."
status_text="Failed"
fi

# Build compact header with optional storybook link
header="## 🎨 Storybook: $status_icon $status_text"
if [ "$deployment_url" != "Not deployed" ] && [ "$deployment_url" != "Deployment failed" ] && [ "$WORKFLOW_CONCLUSION" = "success" ]; then
header="$header β€” $deployment_url"
fi

comment="$COMMENT_MARKER
## 🎨 Storybook Build Status

$status_icon **$status_text**
# Build details section
details="<details>
<summary>Details</summary>

⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC

### πŸ”— Links
**Links**
- [πŸ“Š View Workflow Run]($WORKFLOW_URL)"

# Add deployment status

if [ "$deployment_url" != "Not deployed" ]; then
if [ "$deployment_url" = "Deployment failed" ]; then
comment="$comment
details="$details
- ❌ Storybook deployment failed"
elif [ "$WORKFLOW_CONCLUSION" = "success" ]; then
comment="$comment
- 🎨 $deployment_url"
else
comment="$comment
- ⚠️ Build failed - $deployment_url"
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
details="$details
- ⚠️ Build failed β€” $deployment_url"
fi
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
comment="$comment
details="$details
- ⏭️ Storybook deployment skipped (build did not succeed)"
fi

comment="$comment

---
$footer_text"
details="$details

</details>"

comment="$COMMENT_MARKER
$header

$details"
Comment on lines +174 to +203
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor

Avoid emitting an empty workflow-run link.

If WORKFLOW_URL is unset, the current output renders a dead markdown link. Guard the link so the details block doesn’t include an empty URL.

πŸ”§ Proposed fix
-    details="<details>
-<summary>Details</summary>
-
-⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC
-
-**Links**
-- [πŸ“Š View Workflow Run]($WORKFLOW_URL)"
+    details="<details>
+<summary>Details</summary>
+
+⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC
+
+**Links**"
+
+    if [ -n "$WORKFLOW_URL" ]; then
+        details="$details
+- [πŸ“Š View Workflow Run]($WORKFLOW_URL)"
+    fi
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/cicd/pr-storybook-deploy-and-comment.sh` around lines 175 - 204, The
details block currently always includes a markdown link using $WORKFLOW_URL
which may be empty; update the construction of the details string so the "[πŸ“Š
View Workflow Run]" link is only appended when WORKFLOW_URL is non-empty (e.g.,
test $WORKFLOW_URL and append the "- [πŸ“Š View Workflow Run]($WORKFLOW_URL)" line
into details only if it exists), keeping the rest of the details/header assembly
(variables details, header, comment) unchanged.


post_comment "$comment"
fi
Loading