This project provides an automated deployment solution for a Next.js project using Vercel and Supabase. The solution includes an Express server that handles the deployment process, integrates with Vercel, manages environment variables, and executes SQL on Supabase.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed on your machine. You can install them here.
- An account with Vercel and Supabase.
- An ngrok account for tunneling.
To install the project, follow these steps:
-
Clone this repository:
git clone https://github.com/spark-engine-opensource-projects/Automated-NextJS-deployer-to-vercel-and-supabase.git cd Automated-NextJS-deployer-to-vercel-and-supabase
-
Create a
.env
file in the root directory and add yourNGROK_AUTH_KEY
:NGROK_AUTH_KEY=your-ngrok-auth-key
-
Install the required dependencies by running the bash script:
chmod +x ./run.sh ./run.sh
-
The script will automatically install necessary packages and start the server.
Once the server is running, it will listen on port 3000
and establish an ngrok tunnel.
To deploy a project, you can send a POST request to the /deploy
endpoint with the necessary structure data.
Here's a brief overview of the project structure:
.
├── Deploy.js # Handles deployment to Vercel and Supabase
├── server.js # Express server to manage deployment
├── start-server.js # Script to start the server and ngrok
├── setup-and-start.sh # Bash script to install dependencies and start the server
├── package.json
The following environment variables need to be set in your .env file:
NGROK_AUTH_KEY: Your ngrok authentication token.
POST /deploy This endpoint triggers the deployment process.
Request Body: A JSON object with the following structure:
{
"structure": {
"files": [],
"packageJson": "",
"jsConfigCode": "",
"nextConfigJs": "",
"postcssConfig": "",
"tailwindConfig": "",
"globalsCss": "",
"envVariables": [],
"sqlCode": "",
"keys": {
"SUPABASE_DB_URL": "",
"VERCEL_TOKEN": ""
},
"projectName": "your-project-name"
}
}
Response: Returns 200 if the deployment was successfully started, otherwise 500 with error details.
This project is licensed under the MIT License - see the LICENSE file for details.