How do I get the preview environment URL in a GitHub Action?

Last updated: February 9, 2026

Context

When you deploy preview environments using Porter in a GitHub Action workflow, you may need to get the URL of the preview environment for testing or other purposes. This is particularly useful when setting up automated deployments and tests for pull requests.

Answer

Method 1: Using porter app run (Original Method)

Run the following command to get the domains associated with your preview environment:

porter app run -x <pr-branch-name> <app-name> -- env | grep PORTER_DOMAINS

This will return a comma-separated list of all domains linked to your app.

Note: This method requires the env executable in your container image and won't work with hardened images that don't include it.

Method 2: Using porter app yaml with yq

For hardened images or when you prefer not to run commands inside the container, use:

porter app yaml <app-name> -x <pr-branch-name> | yq '.services[] | select(.name == "<service-name>") | .domains[0].name'

Replace <service-name> with your actual service name.