Deploy command not having a branch option

I found a similar problem on this discussion: Specifying `--git-branch` in `vercel deploy`

The problem is that i am using github actions and vercel CLI to deploy my application. Due to problems on build in github i am not doing the build in Actions and i am sending the deploy directly to Vercel. But when i try to execute run: vercel deploy --token=${{ secrets.VERCEL_TOKEN }} there is no option to specify the branch i want the deploy to run on. So this command makes a preview of the last commit in main, instead of doing it on my branch feature/test-branch

What i am looking for is something like run: vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --git-branch=${{ github.head_ref }} but the flag --git-branch does not exist on this command.

Any alternatives to this? or i am bound to building in github action first?

3 Likes

I haven’t tested this idea myself yet, but you may be able to accomplish something similar with GitHub actions. You’d need to checkout the relevant branch or commit before running the deployment step. If you give it a try, please let me know how it goes!

1 Like

Accidentally deleted my reply :sweat_smile:

Here is a new one for anyone looking into this:

I was using the following documentation to build my CI/CD process with Github Actions: How can I use GitHub Actions with Vercel?

But if you want to build inside Vercel and skip the build in Github this is the code that worked for me:

deploy-preview:
    name: Deploy Preview
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
      - name: Install Vercel CLI
        run: npm install --global vercel@latest
      - name: Deploy Project Artifacts to Vercel
        run: vercel deploy --token=${{ secrets.VERCEL_TOKEN }}

Again thanks @amyegan for the quick solution.

1 Like

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