main → run the workflow → publish a Function version.
This guide uses the Browse CLI to deploy from your repository. It doesn’t connect or continuously sync a repository in the Browserbase dashboard. The workflow publishes code; it doesn’t invoke your automation or set up a schedule.
Prerequisites
- A GitHub repository with Actions enabled and permission to add an Actions secret.
- A standalone npm Function project at the repository root, with
package.json,package-lock.json, andindex.tscommitted. Start with the Functions quickstart if you don’t have a Function yet. - A Browserbase API key for the project you want to deploy to. Browserbase resolves the project from this key; you don’t need to supply a Project ID or log in interactively.
- Any runtime Secrets and extensions required by your Function configured in that project.
browse to 0.11.3, which requires Node.js 22.18 or later. Workspace builds and private package registries are outside this standalone npm recipe.
Prepare the project
From the Function project directory, add the CLI as an exact development dependency:package.json and package-lock.json with your Function source. The workflow uses npm ci to install the locked dependencies and npx --no-install to use that installed CLI. Keep the CLI version and lockfile in sync when upgrading.
Keep .env and other credential files out of Git. Don’t copy credentials into your Function source or workflow YAML.
If your existing project uses pnpm, keep its dependency management consistent. This npm recipe assumes a standalone project with an npm lockfile; don’t add a second package manager’s lockfile just for CI.
Add the deployment secret
In your GitHub repository, open Settings → Secrets and variables → Actions, select New repository secret, and createBROWSERBASE_API_KEY with the key for your destination Browserbase project. See GitHub’s secret setup instructions.
The GitHub secret authenticates deployment. It isn’t automatically available inside a deployed Function. If your handler reads context.secrets, create and attach those Browserbase Secrets separately. Attached Secrets remain attached when you publish a new version of the same Function.
Add the workflow
Create.github/workflows/deploy-functions.yml:
main, including merged pull requests, deploy automatically. To publish manually, open Actions → Deploy Browserbase Functions → Run workflow and select main. Manual runs on another branch skip the deployment job. This example doesn’t deploy from pull request events or make deployment credentials available to them.
The concurrency group permits one deployment job at a time without canceling an active publish. GitHub can replace an older pending run with a newer one; this is deployment of the latest queued code, not a guarantee that every commit is deployed. See GitHub workflow concurrency.
Use a self-contained subfolder
If the complete npm Function project lives infunctions/, add this under the deploy job:
cache-dependency-path: functions/package-lock.json in the setup-node step’s with block. Keep index.ts, package.json, the lockfile, and all imported source inside that folder. The CLI packages the current working directory; pointing at an entrypoint elsewhere doesn’t change the upload root. This adjustment doesn’t make a workspace or monorepo build self-contained.
Verify a deployment
The publish command waits for the remote build. A successful build prints its build ID andbuiltFunctions, including Function IDs and the versions created. A failed build or a polling timeout fails the workflow.
- Open the GitHub Actions run for your commit and check Publish Functions.
- Open Functions in the Browserbase dashboard and confirm the new build and version.
- Keep using the same Function ID for callers. Publishing the same Function name in the same project creates a new version; changing the name creates a different Function.
Troubleshooting
Recover from a code regression
Revert the code change onmain, keeping the same Function name, then let the workflow publish the restored code as another version. Confirm the new build in the dashboard before running the workflow’s callers again. This republishes source; it doesn’t undo external actions or data changes made by earlier invocations.
Deploy a Function
Publish from your local project or the Playground.
Invoke a Function
Run deployed code and inspect its result.