cloudflare / wrangler-action

🧙‍♀ī¸ easily deploy cloudflare workers applications using wrangler and github actions
Apache License 2.0
1.25k stars 159 forks source link

Add deployment-alias-url for pages deployments with Wrangler 3.78.0+ #291

Closed Ambroos closed 1 month ago

Ambroos commented 2 months ago

Since the lovely PR https://github.com/cloudflare/workers-sdk/pull/6643 that landed in Wrangler 3.78.0 it's now possible to get the deployment alias from the pages deploy output too.

This PR exposes that in a backwards compatible way. When there is no alias (or on older Wrangler versions) it'll just not be set.

I tested this in our local repo on commit https://github.com/Ambroos/wrangler-action/commit/6dcec6789d82c53bb800db578877e56cc81c2c45 (which contains dist) but is otherwise identical to this PR, and things seem very functional. Output below:

Run Ambroos/wrangler-action@6dcec6789d82c53bb800db578877e56cc8[1](snip#step:13:1)c2c45
  with:
    wranglerVersion: 3.78.5
    apiToken: ***
    accountId: ***
    workingDirectory: packages/snip
    command: pages deploy "snip" --project-name=snip --branch="ci/use-real-cf-preview-branch-url" --commit-message="ci: use real CF preview branch url" --commit-hash="snip"
    quiet: false
  env:
    PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
🔍 Checking for existing Wrangler installation
  /opt/hostedtoolcache/node/20.17.0/x64/bin/npx --no-install wrangler --version 3.78.5
  ✅ Using Wrangler 3.78.5

🚀 Running Wrangler Commands
  /opt/hostedtoolcache/node/20.17.0/x6[4](snip#step:13:4)/bin/npx wrangler pages deploy style-guide/build --project-name=ui --branch=ci/use-real-cf-preview-branch-url --commit-message=ci: use real CF preview branch url --commit-hash=snip
  Uploading... (5/5)
  ✨ Success! Uploaded 0 files (5 already uploaded)
  🌎 Deploying...
  ✨ Deployment complete! Take a peek over at https://abcdef.snip.pages.dev
  ✨ Deployment alias URL: https://ci-use-real-cf-preview-branc.snip.pages.dev
🏁 Wrangler Action completed

Run echo "### Deployed preview to Cloudflare Pages" >> $GITHUB_STEP_SUMMARY
  echo "### Deployed preview to Cloudflare Pages" >> $GITHUB_STEP_SUMMARY
  echo "🌩ī¸ Preview URL: https://abcdef.snip.pages.dev" >> $GITHUB_STEP_SUMMARY
  echo "đŸŒŗ Branch URL: https://ci-use-real-cf-preview-branc.snip.pages.dev" >> $GITHUB_STEP_SUMMARY
eduardoborges commented 2 months ago

Great work!

Ambroos commented 1 month ago

@Maximo-Guk Would you mind taking a peek? Thanks!

WalshyDev commented 1 month ago

Thank you @Ambroos :)

ashkulz commented 1 month ago

@Maximo-Guk / @WalshyDev, can we have a new release which includes this, please? :slightly_smiling_face: