Deploy apps

The apps deployment pipelines are being invoked upon release using the bit tag or bit snap commands:

bit tag apps/my-app -v 1.0.0 --message 'introducing a new app'
CopiedCopy

You can use one of our official deployers for deploying your app using various methods:

Build a deployer

Build your own deployer by implementing the deploy function in your *.bit-app.ts file in your app component:

import type { AppDeployContext } from '@teambit/application';
import { exec } from 'node:child_process'
import { join } from 'path';

export async function deploy(context: AppDeployContext) {
  const appDir = context.capsule.path;
  // use the Lane ID to deploy for staging environment.
  // const laneId = context.laneId;
  // you can use context to obtain access to your build artifacts.
  const artifactDirectory = join(appDir, 'build');
  
  await exec(`deploy ${artifactDirectory}`, {
    cwd: appDir
  });
};
CopiedCopy

The example above includes a command in your component directory, after the build is completed and all build artifacts are in place.

Staging deployments

You can deploy your apps for staging using bit snaps and lanes for testing and development. Our official are coming with out of the box support for staging deployments for every lane you create for your apps.

If you are using one of our official deployer, create a staging environment by creating and releasing a lane:

bit snap --message 'initial snap for new feature'
CopiedCopy

Alternatively, create a Lane to deploy your app in staging as part of your change request.

bit lane create my-feature
CopiedCopy

If you are building your custom deployer, make sure to use context.laneId or context.capsule.component.id.version to determine whether to deploy for staging or production.

Testing deployments

You can manually deploy your app from the local environment for testing or development purposes.

bit build --include-tag
CopiedCopy

Be careful to cause for unwanted deployments when testing your component deployment! If you need looking to setup a debugger for debugging your build pipeline, head to setup your editor.