This document outlines an improved approach to deploying BasedNet to Vercel using GitHub Actions. This approach offers several advantages over direct deployment from a local machine:
- Consistent Environment: Builds happen in a clean Ubuntu environment, avoiding Windows-specific path issues
- Automated Workflow: Deployments are triggered automatically when you push to the main branch
- Reproducible Builds: Every build uses the same setup, reducing "works on my machine" problems
- Version Control: Deployment configuration is tracked in version control
Before using this deployment method, you'll need:
- A GitHub account with your BasedNet code pushed to a repository
- A Vercel account linked to your GitHub account
- A Vercel project created for BasedNet
- Log in to your Vercel dashboard
- Go to Settings → Tokens
- Create a new token with "Full Account" scope
- Copy the token value (you won't be able to see it again)
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
VERCEL_TOKEN - Value: Paste your Vercel API token
- Click "Add secret"
- From the Vercel dashboard, click "Add New..." → "Project"
- Import your GitHub repository
- Configure your project settings:
- Framework Preset: Next.js
- Root Directory: ./
- Build Command: npm run build
- Output Directory: .next
- Add all required environment variables from your
.envfile - Deploy once manually through the Vercel interface to set up the project
After the initial setup, all future deployments will happen automatically through GitHub Actions when you push to the main branch.
The workflow file .github/workflows/vercel-deploy.yml defines the deployment process:
- Checkout the code from GitHub
- Set up Node.js
- Install dependencies
- Install Vercel CLI
- Pull environment variables from Vercel
- Build the project
- Deploy to Vercel
If you encounter deployment issues:
- Check the GitHub Actions logs for detailed build information
- Verify all required environment variables are set in Vercel
- Ensure your Vercel token has the correct permissions
- Check that the Node.js version in the workflow matches your project requirements
You can also trigger a deployment manually:
- Go to your GitHub repository
- Navigate to Actions → "Deploy to Vercel" workflow
- Click "Run workflow"
- Select the branch you want to deploy
- Click "Run workflow"
This will start the deployment process without requiring a code push.
The GitHub Actions workflow is configured to deploy only on pushes to the main branch and manual triggers. This prevents unauthorized deployments from feature branches.
The Vercel token is stored securely in GitHub Secrets and is never exposed in logs or outputs.