Skip to content
Qyubie Learn
Web Development courseLesson 19 of 20 · tap to see all lessons

Web Development · Beginner

GitHub Workflow and Deployment: Branches, README, Production Builds, Vercel, and Supabase in Production

Organize team work on GitHub, document your project, build for production, deploy a Next.js and Supabase app, configure the live database, and troubleshoot.

  • Qyubie Learn Editorial Team
  • Published
  • 11 min read

Includes 2 quick checks you can do right here.

An app on localhost only helps you. This lesson puts the class portal on the internet, the way teams do it for real: a clean GitHub workflow, documentation a stranger can follow, a production build, a deployment that updates itself when you push, a production database, and a checklist for when something goes wrong.

By the end of this lesson you will be able to:

  • run a team branching workflow with protected main and pull requests,
  • write a README and an .env.example for your project,
  • build and run your app in production mode, and manage environment variables,
  • deploy a Next.js app from GitHub to Vercel,
  • set up a production Supabase database and auth URLs, and
  • verify a deployment and troubleshoot common failures.

A team workflow on GitHub

Lessons 10 and 14 covered branches and pull requests. A team turns them into rules everyone follows:

  1. main is always working. Whatever is on main can be deployed at any moment, so nobody pushes unfinished work there.
  2. One branch per task, named after it: feature/student-search, fix/login-error-message, docs/readme-setup.
  3. Every change reaches main through a pull request, reviewed by at least one teammate.
  4. Small, frequent pull requests beat one giant one at the end. Pull main into your branch often to avoid big conflicts.
  5. Clear commit messages in the imperative: "Add delete confirmation", not "changes" or "final version".

GitHub can enforce rule 3. In your repository's Settings, add a branch protection rule (or ruleset) for main that requires a pull request and an approval before merging. Then nobody, including you, can push to main by accident.

Quick check

Your teammate finished the search feature on their branch. What's the next step in this workflow?

Documentation: README and .env.example

The README.md in your repository's root is the front page of your project on GitHub. Write it for a classmate who has never seen your app and must run it on their own computer. A solid structure:

# Class Portal

A web app for teachers to manage their class lists: sign up, then add, edit,
and remove students. Each teacher sees only their own records.

**Live site:** https://class-portal.example.com

## Features
- Email and password accounts (Supabase Auth)
- Create, edit, and delete student records with validation
- Responsive layout for phones and laptops

## Tech stack
Next.js 16 (App Router), React, TypeScript, Tailwind CSS, Supabase (PostgreSQL and Auth)

## Getting started
1. Install Node.js 20.9 or newer.
2. Clone the repository and run `npm install`.
3. Create a Supabase project and run `supabase/schema.sql` in its SQL Editor.
4. Copy `.env.example` to `.env.local` and fill in your project's URL and publishable key.
5. Run `npm run dev` and open http://localhost:3000.

## Scripts
- `npm run dev`: development server
- `npm run build`: production build
- `npm start`: run the production build
- `npm test`: unit tests

## Team
- Juan Dela Cruz: database and authentication
- Maria Santos: pages and styling

Alongside it, commit:

  • .env.example (lesson 17): every variable name, with fake values. Never the real .env.local.
  • supabase/schema.sql: the SQL that creates your tables, constraints, grants, and policies, so anyone can recreate the database. When you change the database, add the change to this file (or a new numbered file such as supabase/002_add_user_id.sql) in the same pull request as the code that needs it.

Building for production

npm run dev is made for development: it rebuilds on every save and shows detailed errors. Users get the production build, which is optimized and much faster. Always try it locally before deploying:

npm run build
npm run start

npm run build compiles everything and checks your TypeScript. If it reports an error, the deployment would fail the same way, so fix it now. npm run start then serves the production build at http://localhost:3000. Click through your test plan (lesson 18) there.

Environment variables in production

The production site needs the same variables as your .env.local, but they're set on the hosting platform, not in a file in Git. Two rules to remember:

  • NEXT_PUBLIC_ values are inlined at build time. After you change one, the app must be built again, which on a hosting platform means redeploying. Server-only variables are read when the server runs.
  • Production often needs different values than development, such as a different Supabase project (below).

Deploying to Vercel

Next.js apps can be deployed as a Node.js server, a Docker container, a static export, or through adapters for specific platforms. Vercel, the company behind Next.js, connects directly to GitHub and has a free Hobby plan, so it's the easiest starting point. (A Node.js server on your own VPS works too: npm run build, then keep npm run start running with a process manager behind a web server.)

To deploy:

  1. Push your project to GitHub (lesson 5).
  2. Sign in to Vercel with your GitHub account.
  3. Click New Project and select your repository.
  4. On the configuration page, Vercel detects Next.js. Open Environment Variables and add NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY with your production values.
  5. Click Deploy. Vercel installs your packages, runs npm run build, and gives you a live address.

From then on, deploying is automatic:

You...Vercel creates a...
push or merge into your production branch (usually main)production deployment: your live site updates
push to any other branch, or open a pull requestpreview deployment with its own URL, so teammates can test the change before merging

Preview deployments make reviews much better: the reviewer clicks a link and tries the feature, instead of only reading code.

To change a variable later, open your project in the Vercel dashboard, select Environment Variables, choose which environments it applies to (Production, Preview, Development), save, and redeploy. Changes never apply to deployments that already exist.

The production database

Use a separate Supabase project

Use one Supabase project for development and a separate project for production. Then testing, sample data, and experiments can never damage real users' data, and you can practice database changes safely before running them on production.

To set up production:

  1. Create a new Supabase project (for example class-portal-prod).
  2. Run your supabase/schema.sql in its SQL Editor. This is why the schema lives in a file: production gets exactly the same tables, grants, and policies.
  3. Put this project's URL and publishable key in Vercel's Production environment variables.

Never run the "Practice" policies from lesson 16 in production. Before going live, list every policy and read them:

select tablename, policyname, cmd, roles
from pg_policies
where schemaname = 'public'
order by tablename, policyname;

Every write policy should be tied to the user (auth.uid()), as in lesson 17. A using ( true ) on insert, update, or delete means anyone can change your data.

Auth URLs in production

Supabase Auth must know your live address, or confirmation emails will send users back to localhost. In the production project's URL Configuration page:

  • Set Site URL to your production address, such as https://class-portal.vercel.app. Email templates use it through {{ .SiteURL }}.
  • Add your production address to Redirect URLs, for example https://class-portal.vercel.app/**.
  • To let preview deployments log in too, Supabase's docs suggest a wildcard such as https://*-<team-or-account-slug>.vercel.app/** (use your own Vercel slug).

And don't forget the Confirm signup email template change from lesson 17: it's a setting of each Supabase project, so the production project needs it too, and Confirm email should be on.

Quick check

You changed NEXT_PUBLIC_SUPABASE_URL in Vercel's settings, but the live site still uses the old value. Why?

Verifying a deployment

A green "deployed" message only means the build succeeded. Check the live site like a user, with your test plan from lesson 18:

  • The home page loads over https://, with no errors in the DevTools Console.
  • Sign up with a real email: the confirmation email arrives, and its link opens the live site, not localhost.
  • Log in, then create, edit, and delete a record.
  • Log in as a second account: the first account's records are invisible.
  • Logged out, /students redirects to the login page.
  • The site works on a real phone.
  • pg_policies shows no practice policies, and no secret keys appear in the repository.

Troubleshooting

SymptomLikely causeFix
Build fails on Vercel but works locallya TypeScript error you didn't build locally, or an import whose capitalization differs from the file name (Windows and macOS ignore case; Vercel's Linux servers don't)run npm run build locally; match file names exactly
The site loads, but data or login fails, mentioning a missing URL or keyenvironment variables missing in the Production environmentadd them in Vercel, then redeploy
Confirmation emails link to localhostSite URL still set to localhostupdate URL Configuration in the production Supabase project
Login works locally but not on the live sitethe live address isn't in Redirect URLsadd it
Lists are empty in productionthe production database has no tables, grants, or policies yet, or RLS hides the rowsrun schema.sql; check you're logged in
"permission denied for table" (42501)the table has no grant for the rolerun the grant from your schema
A page shows a server erroran exception in server coderead the deployment's logs in the Vercel dashboard; reproduce with npm run build && npm run start locally

When a deployment breaks the live site, the fastest safe fix is usually to undo the change: revert the merge on GitHub (with a pull request, as always), and Vercel deploys the previous working version. Then fix the bug calmly on a branch.

Common mistakes

  • Committing .env.local or pasting secret keys into the README.
  • Skipping the local npm run build and finding errors only on Vercel.
  • Using the development database in production.
  • Forgetting to redeploy after changing environment variables.
  • Leaving Site URL and Redirect URLs pointing at localhost.
  • Leaving practice policies or test accounts in production.
  • Pushing directly to main instead of using pull requests.

Summary

  • Keep main deployable: one branch per task, reviewed pull requests, branch protection, clear commits.
  • Document the project with a README (setup steps, scripts, team), .env.example, and supabase/schema.sql.
  • Run npm run build and npm run start locally before deploying. NEXT_PUBLIC_ values are fixed at build time, so redeploy after changing them.
  • Vercel deploys from GitHub: production deployments from main, preview deployments from branches and pull requests. Set environment variables per environment.
  • Use a separate Supabase project for production, created from schema.sql, with the correct Site URL, Redirect URLs, and email template, and with only user-based policies.
  • Verify the live site with your test plan; troubleshoot with the build output, logs, and environment settings; undo bad changes by reverting.

Next: the final full-stack project, where your team builds and deploys an app of your own.

References and further reading