Next.js Discord

Discord Forum

Deploy via Github actions not setting the correct branch on a preview deploy

Unanswered
Serengeti posted this in #help-forum
Open in Discord
SerengetiOP
Hi,

I have a Github workflow that deploys my Next.js project manually to Vercel on pullrequest open, and every subsequent commit.

For each feature branch, for instance feature/foo I set some Vercel environment secrets as well, such as DATABASE_URL in the workflow.
I verify that these secrets are being set correctly in the Vercel dashboard.

The problem is that the preview deploy being generated by the vercel CLI (run from the workflow) is not referencing the feature/foo branch, but instead it shows HEAD as the branch. Thus, the preview branch does not have the DATABASE_URL set in the environment. Screenshots below.

My relevant deploy code is as follows for the workflow:

name: PR Preview Deploy

on:
  pull_request:
    types: [synchronize, reopened]
  workflow_dispatch:

 - name: Pull Vercel Environment Information
   run: vercel pull --yes --environment=preview --git-branch=feature/foo --token $VERCEL_API_KEY

 - name: Build Project Artifacts
   run: vercel build --token $VERCEL_API_KEY

 - name: Deploy Project Artifacts to Vercel
   run: vercel deploy --prebuilt --token $VERCEL_API_KEY

0 Replies