Help with deployment_url for Playwright tests

Hello,

I would like to ask for some help understanding why the deployment_url sometimes returns different links in GitHub Actions. Let me explain.

I’m currently using Playwright for automated tests, and I configured the tests to use the VERCEL_AUTOMATION_BYPASS_SECRET (as per these instructions), and also configured GitHub actions to check the deployment_status (as per these instructions.

When the tests are triggered in GitHub, I noticed two different patterns (printing the variable) depending on the execution:

  • deployment_url: https://<company_domain>-bcnxcs6xu-<company_domain>-com.vercel.app/ (no staging in the URL). In this case, I have no problems with the tests.

  • deployment_url: https://<company_domain>-staging-bcnxcs6xu-<company_domain>-com.vercel.app/ (contains staging in the URL). In this case, the tests fail when trying to bypass the protection, regardless if bypass secret is set. The same problem happens when I try to run the tests locally.

I would like to know if there’s a logic in which “staging” is appended to the URL. And do you have any idea or advice as to how I can always get the version without staging, where the tests work as expected?

Thank you.

Does the difference appear when deploying to different environments or from specific branches?

The inclusion of -staging makes me think this is related to a custom environment or branch-specific generated URL causing github.event.deployment_status.environment_url to return a different value.

It turns out we deploy to two different environments. And github.event.deployment_status.target_url randomly (I suppose it depends on what gets deployed first?) returns one or the other.

Would you know if there’s an easy way to pick one or exclude the other through the API’s available in github.event.deployment_status ?

One of our engineering managers found the solution to the problem with something along these lines
https://stackoverflow.com/questions/73811903/github-actions-on-vercel-deployment-with-multiple-environments

It’s working for us at the moment.

Thanks for the help Amy!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.