How do deploy to Vercel with GitLab CI? #4853
-
In my view the follwing setup leads to a deeper integration with gitlab than using the gitlab plugin. I set the two env variables deploy-to-vercel:
stage: deploy
image: node:13.10.1-alpine3.10
variables:
PREVIEW_URL=https://$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.$VERCEL_SCOPE.vercel.app
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == 'master'
environment:
name: vercel/$CI_COMMIT_REF_NAME
url: $PREVIEW_URL
script:
- npm i -g vercel
- DEPLOYMENT_URL=$(vercel --name $CI_PROJECT_NAME --confirm -t $VERCEL_TOKEN)
- vercel alias set $DEPLOYMENT_URL $PREVIEW_URL -t $VERCEL_TOKEN
Since I use The sad thing is it took me really long to figure this out
I really like the super simple setup with the git integration, but to integrate in ci I think there is no way around the cli. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 29 replies
-
This is really nice. Thanks for sharing! Really not enough documentation on this. My problem was I still wanted to run tests, etc. before deploying and there doesn't seem to be any flexibility here. Appreciate this solution. |
Beta Was this translation helpful? Give feedback.
-
Yep, been running all over the internet looking for something like this. Never knew I could stumble upon amazing solutions ( to actual issues) in the discussion threads. |
Beta Was this translation helpful? Give feedback.
-
Thank you for this. |
Beta Was this translation helpful? Give feedback.
-
Thats really cool. I tried it and it worked nearly without any changes, thank you! The only thing, I´m not figuring out is: |
Beta Was this translation helpful? Give feedback.
-
Thanks for this great contribution! It’s kinda hard to get clear information on how to handle this and this helped me a lot! Looking into the Vercel docs I ran into this: Using Vercel CLI for Custom Workflows - Using the CLI Without Project Linking and since that pretty much addresses how to properly authenticate the Vercel CLI for deployments without using the deprecated deploy-to-vercel:
stage: deploy
image: node:14-alpine
variables:
PREVIEW_URL: $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.$VERCEL_USER.vercel.app
VERCEL_ORG_ID: $VERCEL_ORG_ID
VERCEL_PROJECT_ID: $VERCEL_PROJECT_ID
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == 'main'
environment:
name: vercel/$CI_COMMIT_REF_NAME
url: https://$PREVIEW_URL
script:
- npm i -g vercel
- DEPLOYMENT_URL=$(VERCEL_ORG_ID=$VERCEL_ORG_ID VERCEL_PROJECT_ID=$VERCEL_PROJECT_ID vercel --confirm -t $VERCEL_TOKEN --scope $VERCEL_USER)
- vercel alias set $DEPLOYMENT_URL $PREVIEW_URL -t $VERCEL_TOKEN --scope $VERCEL_USER Where NotesI changed two things from the original config:
|
Beta Was this translation helpful? Give feedback.
-
Update: It's now much easier to deploy to Vercel with any custom CI/CD provider like self-managed GitLab with GitLab Pipelines! We've created a guide and an example using GitLab Pipelines. Hope this helps! 🙏 |
Beta Was this translation helpful? Give feedback.
-
As far as I know it’s not possible atm.
…On Mon, 19 Sep 2022 at 14:33, Berci ***@***.***> wrote:
Thank you for your input!
Indeed that was the case. we did disconnected the gitlab integration, and
it seem to work just fine.
I was wondering if there is any way to also keep the gitlab data in the
vercel though (it would be nice to see from vercel what branch triggered
the deploy, for example) .
—
Reply to this email directly, view it on GitHub
<#4853 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNDTYVQBYFBVUOAATFO4LTV7BMQHANCNFSM4OZWWUFQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I mean that at least to my current knowledge when you deploy to Vercel via
Gitlab it won’t display the branch on the deployment list inside your
Vercel dashboard. Instead it will show smth like “via CLI” or similar.
Can’t recall right now.
Also there is this nice MR summary that is added as a comment to every MR
if you use Vercel Gitlab integration. That will be missing as well (it’s
3rd party plug-in you can add it in your Vercel dashboard)
…On Mon, 19 Sep 2022 at 20:08, Amy ***@***.***> wrote:
Hi @mkbctrl <https://github.com/mkbctrl>! Can you clarify what you mean?
It is possible to use GitLab Pipelines with Vercel
<https://vercel.com/guides/how-can-i-use-gitlab-pipelines-with-vercel>,
but maybe you are talking about something more specific that I missed.
—
Reply to this email directly, view it on GitHub
<#4853 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNDTYVCLF6VXBAUATFG6XDV7CTZ3ANCNFSM4OZWWUFQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Update: It's now much easier to deploy to Vercel with any custom CI/CD provider like self-managed GitLab with GitLab Pipelines!
We've created a guide and an example using GitLab Pipelines. Hope this helps! 🙏