Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the URL after a pages preview deployment? #81

Closed
LittleSound opened this issue Aug 18, 2022 · 6 comments
Closed

How do I get the URL after a pages preview deployment? #81

LittleSound opened this issue Aug 18, 2022 · 6 comments

Comments

@LittleSound
Copy link

LittleSound commented Aug 18, 2022

I want to use the preview deployment of pages in PR and add URL to environment, but I don't know how to get the "Preview URL", it's not written in the documentation.

Desired effect

jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy
    environment:
      name: dev-preview
      url: ${{ steps.builddeploy.outputs.web_app_url }}
    steps:
      - uses: actions/checkout@v3
      - name: Publish
        uses: cloudflare/wrangler-action@2.0.0
        with:
          apiToken: ${{ secrets.CF_API_TOKEN }}
          accountId: ${{ secrets.CF_ACCOUNT_ID }}
          command: pages publish --project-name=example

When this CI is run you will see:
image

@microHoffman
Copy link

Is there any way how to do this currently? Given that cloudflare also trims the branch name alias deploy url after certain characters, this is must have for us to be able to display deployed preview url in the PR comments. Thanks!

@Erisa
Copy link

Erisa commented Mar 23, 2023

You can use Pages action: https://github.com/cloudflare/pages-action

@polaroidkidd
Copy link

so the pages action will deprecated at some point in the future - cloudflare/pages-action#131 (comment)

How would we do this with the wrangler-action?

@Erisa
Copy link

Erisa commented Jul 8, 2024

For what its worth, I don't work at Cloudflare anymore.

But I do see @polaroidkidd that this action now has outputs for deployment URLs: https://github.com/cloudflare/wrangler-action?tab=readme-ov-file#using-the-deployment-url-output-variable

There is an example on that README which shows how you access it through .outputs:

- name: Deploy
  id: deploy
  uses: cloudflare/wrangler-action@v3
  with:
    apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
    accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
    command: pages deploy --project-name=example

- name: print deployment-url
  env:
    DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
  run: echo $DEPLOYMENT_URL

@polaroidkidd
Copy link

A, thanks. I was hoping for a option similar to what the pages action supplied. I looked into the action a bit and it's a lot more involved than just setting a flag to display the information in the action run or on the PR. Echoing it out will do for now though. Thanks!

@Ambroos
Copy link
Contributor

Ambroos commented Sep 19, 2024

For reference, once #291 lands you will also have steps.deploy.outputs.deployment-alias-url available as long as you use the action with Wrangler 3.78.0+ to get the branch alias for the preview URL.

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

No branches or pull requests

6 participants