Skip to content

preview-cloudflare: Use branch alias URL instead of hash URL in PR comments #14

Closed

Description

@mmcky

Summary

The preview-cloudflare action currently extracts the deployment hash URL from wrangler output and uses it in PR comments. It should prefer the branch alias URL instead.

Current Behavior

PR comment shows:

Preview URL: https://b3a5c314.quantmfr.pages.dev

Expected Behavior

PR comment should show:

Preview URL: https://pr-1.quantmfr.pages.dev

Why This Matters

The branch alias URL (pr-{number}.{project}.pages.dev) is preferred because:

  1. Predictable - Always the same format for each PR number
  2. Updates automatically - Points to the latest deployment when new commits are pushed
  3. Easier to share - Reviewers know where to look without needing to check comments for each push

The hash URL is specific to a single deployment and doesn't update when new commits are pushed to the PR.

Suggested Fix

In preview-cloudflare/action.yml, change the URL extraction logic to construct the branch alias URL directly since we already have all the components:

# Instead of extracting from wrangler output:
# DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep -oE 'https://[a-zA-Z0-9.-]+\.pages\.dev' | head -1)

# Construct the branch alias URL directly:
DEPLOY_URL="https://${BRANCH_ALIAS}.${PROJECT_NAME}.pages.dev"

Related

Identified during testing in QuantEcon/QuantMFR#1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions