This repository shows how to deploy a Next.js app to Contentstack Launch using the Launch Public API file upload with GitHub Actions. The workflow (.github/workflows/deploy.yml) runs on push to main and uses the deployment script deploy-api.js.
The Launch API supports M2M, OAuth, or Authtoken. This repo uses M2M (Client ID + Client Secret).
| Variable | Description |
|---|---|
CONTENTSTACK_CLIENT_ID |
M2M/OAuth app ID |
CONTENTSTACK_CLIENT_SECRET |
M2M/OAuth app secret |
CONTENTSTACK_REGION |
Region: AWS_NA, AWS_EU, AWS_AU, AZURE_NA, AZURE_EU, GCP_NA, GCP_EU |
PROJECT_UID |
Launch project UID |
ENVIRONMENT_UID |
Launch environment UID |
- Clone or copy this repo.
- Create an app with
launch:manageorlaunch.projects:writescope (this repo uses M2M; OAuth/Authtoken are also supported by the API). - Set the required variables as GitHub Actions secrets, or use
.envfor local runs. - Push to
main(or runnpm run deploylocally).
Run locally: Copy .env.example to .env, fill in values, then run npm run deploy.
Workflow: .github/workflows/deploy.yml — on push to main: checkout → npm install → node deploy-api.js.
Secrets (Settings → Secrets and variables → Actions): CONTENTSTACK_CLIENT_ID, CONTENTSTACK_CLIENT_SECRET, CONTENTSTACK_REGION, PROJECT_UID, ENVIRONMENT_UID.
The deploy script (deploy-api.js) zips only the files and folders listed in the essentialFiles array inside createZipFile(). There is no config file — the list is hardcoded.
Default list: package.json, package-lock.json, next.config.js, pages, public, app, functions
To customize: Edit deploy-api.js and change the essentialFiles array in createZipFile() so it matches your project (e.g. add src, components, or lib; remove app or functions if you don’t use them). Only entries in that array are included in the zip.