Vercel is a platform that provides Serverless services, making it particularly suitable for proxying static pages or creating simple APIs. Its free plan is very friendly to personal projects, especially with good CDN support in China. However, for projects hosted under GitHub organizations, Vercel usually requires an upgrade to the paid Pro plan. This article will introduce a method to bypass this restriction and use Vercel services for free.
Background
Vercel's Hobby plan provides free hosting services for personal projects and is widely popular among developers. However, when a project is hosted under a GitHub organization, Vercel requires a paid upgrade by default. This undoubtedly adds to the burden for small teams or developers with limited budgets. Therefore, we need to find a way to create a Vercel project that is not bound to GitHub, allowing us to take advantage of the free services.
Creating a Vercel Project Not Bound to GitHub
First, we need to use the Vercel command-line tool to create a project independent of GitHub.
Installing Vercel CLI
Run the following command in your terminal to install Vercel CLI globally:
npm install -g vercel
Creating a Vercel Project
Enter your project directory, then run the following commands:
vercel login
vercel
During this process, you will see an interactive terminal interface. Follow the prompts step by step, and you will be able to create a service on Vercel that is not connected to any GitHub project. If the deployment succeeds, you can access the deployed service through the Vercel web interface. At this point, we have completed half of the work.
Setting Up Automatic Deployment
Next, we need to set up automatic deployment to Vercel after each code commit. We will use GitHub Actions to implement this functionality.
Configuring GitHub Actions
Create a CI configuration file in your GitHub repository and add the following steps after the build operation:
- name: Deploy to Vercel
uses: amondnet/vercel-action@master
env:
VERSION: ${{ env.GITHUB_SHA }}
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}
working-directory: ./
vercel-args: '--prod' # 可选参数
Preparing GitHub Secrets
Before using the GitHub Action above, you need to set the following parameters in GitHub Secrets:
- VERCEL_TOKEN: Create one on the Vercel account page.
- ORG_ID and PROJECT_ID: These can be found in the
.vercel/project.jsonfile in the project root directory.
Through the steps above, you can implement automated deployment for team projects and enjoy Vercel's services completely free of charge.
Summary
By cleverly using Vercel CLI and GitHub Actions, we can circumvent Vercel's paid restriction for projects belonging to GitHub organizations. This method not only saves costs but also improves the efficiency of automated project deployment, making it particularly suitable for small teams or individual developers. We hope this article helps you get your team project online quickly without increasing your budget!