cloudflare / pages-action

MIT License
473 stars 97 forks source link

Add per-branch alias URL to output value #18

Closed ngbrown closed 1 year ago

ngbrown commented 2 years ago

Currently the only output URL is the unique-per-deployment URL. Each branch also has an alias that could be preferable to visit, especially because of login sessions.

I would combine this with #14 to specify the branch in the case of pull request builds. Because those show up only as HEAD, because GitHub is actually building on a test-merge commit.

rohit-gohri commented 1 year ago

I think this is still an issue, the output of the example workflow doesn't return the correct alias - https://github.com/cloudflare/pages-action/actions/runs/3631522134/jobs/6126266418#step:4:11

Haven't tested in my repo yet

WalshyDev commented 1 year ago

I think this is still an issue, the output of the example workflow doesn't return the correct alias - cloudflare/pages-action/actions/runs/3631522134/jobs/6126266418#step:4:11

Haven't tested in my repo yet

That was for production, production doesn't have an alias so it can't return one. What would you expect there?

rohit-gohri commented 1 year ago

The main url, https://github-actions-example.pages.dev/ ? Since that is the "alias" for production

peschee commented 1 year ago

I am also running into this issue. Given this simple config:

      - name: Publish to Cloudflare Pages
        uses: cloudflare/pages-action@v1.2.0
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: yyy
          projectName: xxx
          directory: zzz
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
        id: publish

I get this alias in these outputs from the action when running in on a branch (e.g. in a PR)

ID: 8a8296e1-e646-45ca-9bae-9ed8001c7fb9
URL: https://8a8296e1.xxx.pages.dev
Environment: preview
Alias: https://head.xxx.pages.dev

I guess head is wrong here?

peschee commented 1 year ago

Maybe related to #22 ?

peschee commented 1 year ago

When I add the branch parameter, I do not get the head alias, but the alias still seems wrong. The action outputs are:

ID: 2640a0f7-9755-4666-b3c7-046b95704a59
URL: https://2640a0f7.xxx.pages.dev
Environment: preview
Alias: https://2640a0f7.xxx.pages.dev

but the alias Cloudflare Pages assigns would be something like branch-name.xxx.pages.dev when the PR branch is branch-name and my domain is xxx.

Run cloudflare/pages-action@v1.2.0
  with:
    apiToken: ***
    accountId: yyy
    projectName: xxx
    directory: dist
    gitHubToken: ***
    branch: branch-name
peschee commented 1 year ago

Funnily enough, any subsequent push (and deployment) of a PR branch uses the right alias…

EDIT: no it does not. I think we might be running into #29 here, since sometimes it works and sometimes it does not.

sastan commented 1 year ago

I have created a PR (#40) that tries to fix this issue.

IanVS commented 1 year ago

It seems like this should be re-opened, right? I'm not getting the alias in the output.