wait-for-vercel-preview
wait-for-vercel-preview copied to clipboard
Support multiple preview deployments per Pull request
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.
Any plans to fix this @patrickedqvist we'd be happy to sponsor you if this is fixed :)
@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
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 @MarkLyck @nc
How do you see this being done?
I see 2 things that could be nice
- 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
- 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?
@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
@pip8786 How did you find the name of the environment? I am creating a preview deployment with
testingbranch 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_urlfield value from the output variable to the general latest branch deployment URLhttps://[projectName]-git-[branchName]-[gitUserName].vercel.appin 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.
@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.