Hello Community,
We are using the Github integration to deploy preview environments.
Our app consist of a backend and a frontend, the latter being deployed by Vercel.
The URL of the backend being deterministic (e.g. https://pr-${PR_ID}.my-backend.com
), we use the process.env.VERCEL_GIT_PULL_REQUEST_ID
in the frontend to know where to look for the backend.
This behavior works for PR on which we iterate, but the very first deployment - right after pushing the branch and creating the PR - does not have the PR ID. Any deployments happening after that (by pushing a new commit) deploys the environment correctly and includes the PR ID.
We tried using the “Ignore Build Step” feature with the following, but the result is that the first deployment (when creating the PR) is simply skipped, creating the PR does not deploy anything:
[ "$VERCEL_GIT_COMMIT_REF" == "main" ] || [ -n "$VERCEL_GIT_PULL_REQUEST_ID" ] && exit 1 || exit 0
Is there a way to force a redeploy when the PR is created?
Steps to reproduce:
- Enabled Github integration and preview builds
- Create new branch and some commit
- Push to remote branch
- Create PR
Expected result:
- The initial (branch) deployment is updated (as a PR deployment) with
$VERCEL_GIT_PULL_REQUEST_ID
set
Actual result:
- The (branch) deployment is not updated,
$VERCEL_GIT_PULL_REQUEST_ID
is empty - We need to push another commit to force a redeployment and have the PR ID available