Skip to content

CICD-401 · PR comment with deployment URL ​

Encyclopedia · Preview environments and developer experience · All snippets

Previous · CICD-400 · Next · CICD-402

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 PREVIEW_URL, PR_NUMBER, TARGET_REPO.

2. Copy the snippet ​

bash
[[ "${PR_NUMBER:?}" =~ ^[0-9]+$ ]]
gh pr comment "$PR_NUMBER" --repo "${TARGET_REPO:?}" --body "Preview: ${PREVIEW_URL:?}" --edit-last --create-if-none

3. How it works ​

The CLI posts the preview URL to the selected PR and repository. Its edit-or-create behavior suits a dedicated preview bot with an existing announcement.

4. Verify the result ​

Post using a bot dedicated to previews and construct the URL from trusted components. Verify repository and PR linkage.

Validation syntax-validated (Bash parse). Status definitions.