How do I get the preview environment URL from a GitHub workflow?
Last updated: September 9, 2025
Context
When using Porter preview environments with GitHub workflows, you may need to obtain the preview environment URL programmatically to run integration tests or other automated tasks in your CI/CD pipeline.
Answer
You can retrieve the preview environment URL using the Porter CLI within your GitHub workflow. After the preview environment is deployed for the first time, use the following command:
porter app yaml -x <pr-branch-name> <app-name> | yq '.services[] | select(.name == "<service-name>") | .domains[0].name'Replace the following parameters:
<pr-branch-name>: The name of your pull request branch<app-name>: The name of your Porter application<service-name>: The name of the preview environment application service
This command will output the domain name for the web service of your preview environment.