wait-for-vercel-preview icon indicating copy to clipboard operation
wait-for-vercel-preview copied to clipboard

Support multiple preview deployments per Pull request

Open MarkLyck opened this issue 2 years ago • 8 comments

This action works great for projects with a single Vercel deployment.

But in my case my project has 3 vercel deployments per project, and currently this action only returns the URL for the first one that runs which is random.

I would like to either have it run on all preview deployments when they are succesful or a specific one. But this doesn't seem to be supported.

MarkLyck avatar Dec 22 '22 03:12 MarkLyck

Any plans to fix this @patrickedqvist we'd be happy to sponsor you if this is fixed :)

nc avatar Jan 04 '23 00:01 nc

@MarkLyck we're able to wait on a specific environment by doing this:

steps:
      - name: Wait for Vercel preview deployment to be ready
        uses: patrickedqvist/[email protected]
        id: waitForVercelPreviewDeployment
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          max_timeout: 600
          environment: Preview – web-app

We have 2 deployments that happens each time, but currently only interested in running on a specific one. I'm not sure about running on all of them though, maybe that would require separate actions?

Edit to add: here's the line where it passes the environment to octokit: https://github.com/patrickedqvist/wait-for-vercel-preview/blob/c934e81c4b18ad59acbb866fb817ed586b17ecba/action.js#L218 which I believe is this API: https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#list-deployments

pip8786 avatar Jan 24 '23 15:01 pip8786

I would love to implement this, I'm going to work on a project soon where I might be able to develop this feature properly at the same time. I happily accept contributions as well ;)

patrickedqvist avatar Jan 25 '23 13:01 patrickedqvist

@patrickedqvist @MarkLyck @nc

How do you see this being done?

I see 2 things that could be nice

  1. The ability to specify multiple environments, the action checks on each one but returns whichever is first. This would be useful for when you only care about one site/project (in our case, E2E Build) but different branches cause the environments to be named differently. This is the use case I have and how I stumbled on this issue. I have an ugly fork doing this
Production - MySite
Staging - MySite
  1. Not my current use case but it might be yours, which is, the ability to specify multiple environments and wait for each one. The action would then return an object with property names of the environments you specified with its corresponding URL. Something like
waitFor200.outputs['Staging - MySite'].url
waitFor200.outputs['E2E - MySite'].url
waitFor200.outputs['Demo - MySite'].url

What do you think?

hjoelh avatar Mar 14 '23 21:03 hjoelh

@pip8786 How did you find the name of the environment? I am creating a preview deployment with testing branch so I tried: "Preview - testing", "testing" and "Preview", but none of them works (no deployments found).

A workaround solution I use now, is to change the preview_url field value from the output variable to the general latest branch deployment URL https://[projectName]-git-[branchName]-[gitUserName].vercel.app

in my case:

outputs:
      preview_url: https://jobs-git-testing-filipkowal.vercel.app

filipkowal avatar Dec 04 '23 16:12 filipkowal

@pip8786 How did you find the name of the environment? I am creating a preview deployment with testing branch so I tried: "Preview - testing", "testing" and "Preview", but none of them works (no deployments found).

A workaround solution I use now, is to change the preview_url field value from the output variable to the general latest branch deployment URL https://[projectName]-git-[branchName]-[gitUserName].vercel.app

in my case:

outputs:
      preview_url: https://jobs-git-testing-filipkowal.vercel.app

Hey @filipkowal, the name of the environment is whatever this says for you. Can be Production, Preview, Preview - YourApp, Production - YourApp etc.

CleanShot 2023-12-04 at 4  17 11

hjoelh avatar Dec 04 '23 16:12 hjoelh

@filipkowal Just confirming that what @hjoelh posted is correct. That part of the comment from Vercel is what we used to filter the Github action by environment.

pip8786 avatar Dec 04 '23 16:12 pip8786