Deployment
Prerequisites
Node.js 24 is required. All commands that invoke Node.js, npm, or wrangler must be run under nvm use 24.
source ~/.nvm/nvm.sh && nvm use 24
Build
The build step bundles frontend JavaScript via esbuild, copies HTML files from public/ to static/ (rewriting asset paths), builds documentation with docmd, and generates a help redirect page.
npm run build
This produces:
static/panel-bundle.js– deal sidebar panelstatic/settings-bundle.js– settings pagestatic/field-modal-bundle.js– field comparison modalstatic/docs/– documentation sitestatic/*.html– HTML pages copied frompublic/
All build artifacts in static/ are gitignored.
Deploy
Production deployment is handled by Cloudflare Workers Builds from the connected GitHub repository. Local development should verify the build and tests, then push to origin/master; the push triggers Cloudflare to build and deploy the Worker.
npm run build
npm test
git push origin master
Do not use wrangler deploy locally as the normal deployment path. npm run deploy is intentionally disabled and exits with instructions to push to origin/master instead.
Configure Cloudflare Workers Builds with:
| Setting | Value |
|---|---|
| Root directory | repository root |
| Production branch | master |
| Build command | npm run build |
| Deploy command | npx wrangler deploy |
| Non-production branch deploy command | npx wrangler versions upload |
Cloudflare documents Workers Builds as a two-step process: an optional build command that compiles the project, followed by a deploy command that defaults to npx wrangler deploy. Non-production branch builds default to npx wrangler versions upload, which creates a preview version without promoting it to production.
Database Migrations
Migrations live in the migrations/ directory. Each new migration must be applied to production D1 before deploying the worker that depends on it:
source ~/.nvm/nvm.sh && nvm use 24
npx wrangler d1 execute pipedrive-utilities-db --remote --file=./migrations/<migration_file>.sql
npm run build
npm test
git push origin master
For local development, apply migrations with:
npx wrangler d1 execute pipedrive-utilities-db --local --file=./migrations/<migration_file>.sql
The db:migrate:local and db:migrate:remote npm scripts only run 0001_init.sql. For newer migrations, use the npx wrangler d1 execute command directly as shown above.
Secrets
The following secrets must be set via wrangler secret put <NAME>:
| Secret | Purpose |
|---|---|
PIPEDRIVE_CLIENT_ID |
Pipedrive OAuth2 application client ID |
PIPEDRIVE_CLIENT_SECRET |
Pipedrive OAuth2 application client secret |
SESSION_SECRET |
Secret used to sign session cookies |
CUSTOM_MODAL_ACTION_ID |
Pipedrive custom action ID for the field comparison modal |
GOOGLE_ADS_DEVELOPER_TOKEN |
Google Ads API developer token |
GOOGLE_ADS_CLIENT_ID |
Google Ads OAuth2 client ID |
GOOGLE_ADS_CLIENT_SECRET |
Google Ads OAuth2 client secret |
Environment Variables
Defined in wrangler.toml under [vars]:
| Variable | Purpose |
|---|---|
BASE_URL |
Canonical public URL of the deployed worker, without a trailing slash: https://pipedrive-utilities.sessions.edu. This must match the production custom domain because it is used for OAuth redirect URIs and callback links. |
Custom Domain Changes
When moving the Panel from the default workers.dev hostname to a custom domain:
- Attach the custom domain or route to the
pipedrive-utilitiesWorker in Cloudflare. - Update
BASE_URLinwrangler.tomlto the custom domain:https://pipedrive-utilities.sessions.edu. - Update the Pipedrive app’s custom UI iframe URLs:
/panel/settings/field-modal
- Update the Pipedrive app’s OAuth redirect URL to:
/auth/callbackon the same custom domain.
- Confirm Cloudflare Workers Builds is still deploying the same Worker name from
wrangler.toml. - Push the change to
origin/master; Cloudflare will build and deploy it.
The app also builds links to /docs/, /settings, /panel, /field-modal, and /portal-request as same-origin paths, so no code change is normally needed for those routes beyond setting the canonical BASE_URL and updating the Pipedrive developer configuration.
Wrangler Bindings
| Binding | Type | Description |
|---|---|---|
DB |
D1 Database | Cloudflare D1 database (pipedrive-utilities-db) |
ASSETS |
Static Assets | Serves files from ./static |