Using the CLI
Spinning up an isolated preview environment is as simple as running the following command:Customizing Github Actions
Porter uses Github Actions to build and deploy your apps. When setting up preview environments, a workflow file with a name likeporter-preview-<app-name>.yml will be created in your repository. You can customize this file to suit your needs.
For example, it is possible to add conditionals to only run the workflow for specific branches or tags. This can be useful if you want to only create preview environments when a specific branch naming convention is used. If you only want to create preview environments for branches that start with feat/, you can add the following to your workflow file:
Opening a shell
In cases where you need to open a shell into a preview env’s running apps, you need to first retrieve the preview env name and then runporter app run:
- Retrieve the preview env name by running
porter target list --preview. Copy the name of the preview env you’d like to open a shell into. - Next, run
porter app run <APP_NAME> -x <TARGET_NAME> -- <COMMAND>where<APP_NAME>is the name of the underlying app the preview env uses as a template, and<TARGET_NAME>is the preview env name you copied from running the first command. This will spin up a new replica and open a shell; if you wish to use an existing running replica, add the-eflag toporter app run.

