CICD-397 · Dynamic preview URL generation
Encyclopedia · Preview environments and developer experience · All snippets
Previous · CICD-396 · Next · CICD-398
1. Where it fits
- Placement CI run step or authorized lab terminal.
- Prerequisites trusted preview controller, disposable environment and scoped identities for external resources.
- Platforms kubernetes, local-lab.
- Parameters
GITHUB_OUTPUT,PREVIEW_DOMAIN,PR_NUMBER.
2. Copy the snippet
bash
[[ "${PR_NUMBER:?}" =~ ^[0-9]+$ ]]
[[ "${PREVIEW_DOMAIN:?}" =~ ^[A-Za-z0-9.-]+$ ]]
printf 'preview_url=https://pr-%s.%s\n' "$PR_NUMBER" "$PREVIEW_DOMAIN" >> "$GITHUB_OUTPUT"3. How it works
The service only uses a numeric PR ID and approved domain text to build the URL. Writing it to GITHUB_OUTPUT gives later steps a named value to consume.
4. Verify the result
Feed a trusted base domain and numeric PR ID into the output. The DNS and ingress setup still needs provisioning.
Validation syntax-validated (Bash parse). Status definitions.