If env variables can only be updated with a build, how can I set env variable with the preview URL
Unanswered
Hussam posted this in #help-forum
HussamOP
I am using Turborepo with 3 apps,
I have a CI/CD pipeline for preview deployment
How can I update my .env variables such that each app has access to its preview URL as well as the other 2 preview URLs?
For its preview URL, I can make use of VERCEL_URL, how can I get access to the other preview URLs from an app?
if the preview URL can only be accessed after a build completes, I would need to do another build to update the URL, maybe the new deployment will have a different URL. but, I don't want to build the same thing twice anyway.
Note: I don't want to use
I have a CI/CD pipeline for preview deployment
How can I update my .env variables such that each app has access to its preview URL as well as the other 2 preview URLs?
For its preview URL, I can make use of VERCEL_URL, how can I get access to the other preview URLs from an app?
if the preview URL can only be accessed after a build completes, I would need to do another build to update the URL, maybe the new deployment will have a different URL. but, I don't want to build the same thing twice anyway.
Note: I don't want to use
vercel alias, as I need a unique URL for every PR.name: Vercel Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches-ignore:
- main
jobs:
Deploy-Preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: echo preview_url=$(vercel deploy --prebuilt --token=${{ env.VERCEL_TOKEN }} --cwd apps/web) >> $GITHUB_OUTPUT
- name: Print preview url
run: echo ${{ steps.deploy.outputs.preview_url }}