This guide explains how to set up Grainlify for deployment on Vercel through GitHub Actions. The deployment workflow automates production and preview deployments automatically on push and pull requests.
- Vercel account with admin access
- GitHub repository administrator access
- Frontend and Website projects already created in Vercel
- Log in to Vercel Dashboard
- Go to Settings → Tokens
- Click Create Token
- Set name:
grainlify-github-actions - Select scope: Full Account
- Click Create Token
- Copy the token (you won't see it again)
- Go to Vercel Dashboard
- In the sidebar, hover over your team/account name
- Look for the ID format:
tm_oracct_ - Or navigate to Settings → General and find ID field
- Copy the Organization/Team ID
For each project (frontend, website):
- Go to the project in Vercel Dashboard
- Click Settings
- Find the Project ID field
- Copy the Project ID
Repeat for both:
VERCEL_PROJECT_ID_FRONTEND- ID from frontend projectVERCEL_PROJECT_ID_WEBSITE- ID from website project
- Go to GitHub repository
- Click Settings tab
- Go to Secrets and variables → Actions
- Click New repository secret
- Add each secret:
| Secret Name | Value |
|---|---|
VERCEL_TOKEN |
Your Vercel token from Step 1 |
VERCEL_ORG_ID |
Your organization ID from Step 2 |
VERCEL_PROJECT_ID_FRONTEND |
Frontend project ID from Step 3 |
VERCEL_PROJECT_ID_WEBSITE |
Website project ID from Step 3 |
gh secret set VERCEL_TOKEN --body "your_token_here"
gh secret set VERCEL_ORG_ID --body "your_org_id"
gh secret set VERCEL_PROJECT_ID_FRONTEND --body "frontend_project_id"
gh secret set VERCEL_PROJECT_ID_WEBSITE --body "website_project_id"For each Vercel project, ensure the following are configured:
VITE_API_URL=https://api.grainlify.com
VITE_APP_ENV=production
NEXT_PUBLIC_APP_ENV=production
Frontend:
- Framework: Vite
- Build Command:
npm run build - Output Directory:
dist
Website:
- Framework: Next.js
- Build Command:
npm run build - Output Directory:
.next
- Create a new feature branch
- Make some changes to
frontend/orwebsite/ - Push branch and create a PR
- GitHub Actions will create a preview deployment
- Check PR comments for preview URLs
- Merge PR or push directly to
main - Check GitHub Actions for deployment status
- Verify deployment in Vercel Dashboard
The workflow automatically:
On Push to main/develop/master (Production):
- Deploys frontend to production
- Deploys website to production
- Creates permanent production URLs
On PR to main/develop/master (Preview):
- Creates preview deployments with unique URLs
- Comments on PR with preview links
- Allows testing before merging
- ✅ Verify
VERCEL_TOKENis set and has proper permissions - ✅ Check token hasn't expired
- ✅ Verify
VERCEL_ORG_IDmatches Vercel account
- Check GitHub Actions logs: Actions → select workflow → view logs
- Verify all environment variables are set
- Check Vercel project settings match workflow expectations
- Verify
VERCEL_PROJECT_ID_FRONTENDandVERCEL_PROJECT_ID_WEBSITEIDs - Check that frontend is deploying to frontend project, website to website project
- Ensure all dependencies are correct
- Check build scripts in
package.json - Verify environment variables are set in Vercel project settings
To rotate the Vercel token periodically:
- In Vercel, create a new token
- In GitHub, update
VERCEL_TOKENsecret with new token - In Vercel, delete the old token
Preview URLs follow this format:
https://grainlify-git-branch-name-deployer-username.vercel.app
Production URLs depend on your Vercel domain:
https://grainlify.com (main domain)
or
https://grainlify-prod.vercel.app (Vercel domain)