Post (or update) a pull request comment containing a table of preview environment URLs.
Supports multiple services, a <pr_number> placeholder in URLs, optional label gating, and customisable header/footer text. Subsequent runs update the same comment instead of creating duplicates.
The <pr_number> placeholder in every service URL value is replaced with the actual PR_NUMBER input before the comment is posted.
When LABEL is set, the entire job is skipped unless the PR carries that label — useful for on-demand preview environments that are only deployed when a specific label is applied.
COMMENT_TAG is passed to thollander/actions-comment-pull-request which finds an existing comment with the same tag and edits it. This means re-running the workflow (e.g., after redeploying) updates the comment in-place instead of spamming the thread.
The comment body is written to a temp file to correctly handle multiline MESSAGE_FOOTER values.
The SERVICES value is a JSON string, not a YAML map — it must be passed as a single-quoted JSON string in the with: block.
ArgoCD's Pull Request Generator watches a repository's open PRs via the GitHub API. When a PR matches the configured filter (typically carrying a specific label such as preview), the ApplicationSet controller automatically creates a dedicated ArgoCD Application — and therefore a full preview environment — for that PR. When the label is removed or the PR is closed/merged, ArgoCD destroys the environment.
The ApplicationSet below uses the Pull Request Generator to watch a GitHub repository for PRs labelled preview, and deploys each one to its own namespace:
This is a complete pull-request workflow that triggers on label events, builds and pushes a preview image, then posts the comment. The LABEL: preview input on preview-comment ensures the comment step is skipped if the workflow was triggered for a different label.
preview-comment.ymlPost (or update) a pull request comment containing a table of preview environment URLs.
Supports multiple services, a
<pr_number>placeholder in URLs, optional label gating, and customisable header/footer text. Subsequent runs update the same comment instead of creating duplicates.Inputs
<pr_number>as a placeholder for the PR number.<pr_number>in URL templates and to target the comment)🤖 Hey !Please be patient, deployment may take a few minutes. […]preview'["ubuntu-24.04"]'or'["self-hosted", "linux"]')["ubuntu-24.04"]Permissions
Notes
<pr_number>placeholder in every service URL value is replaced with the actualPR_NUMBERinput before the comment is posted.LABELis set, the entire job is skipped unless the PR carries that label — useful for on-demand preview environments that are only deployed when a specific label is applied.COMMENT_TAGis passed tothollander/actions-comment-pull-requestwhich finds an existing comment with the same tag and edits it. This means re-running the workflow (e.g., after redeploying) updates the comment in-place instead of spamming the thread.MESSAGE_FOOTERvalues.SERVICESvalue is a JSON string, not a YAML map — it must be passed as a single-quoted JSON string in thewith:block.Examples
Single service
Multiple services with label gate
The comment is only posted when the PR has the
previewlabel, matching a workflow that only deploys preview environments when that label is present.Custom header and footer
ArgoCD preview environment context
This workflow is designed as the notification layer in a broader ArgoCD pull request preview pattern. The full setup works as follows:
How it works
ArgoCD's Pull Request Generator watches a repository's open PRs via the GitHub API. When a PR matches the configured filter (typically carrying a specific label such as
preview), the ApplicationSet controller automatically creates a dedicated ArgoCDApplication— and therefore a full preview environment — for that PR. When the label is removed or the PR is closed/merged, ArgoCD destroys the environment.ApplicationSet example
The ApplicationSet below uses the Pull Request Generator to watch a GitHub repository for PRs labelled
preview, and deploys each one to its own namespace:End-to-end GitHub Actions workflow
This is a complete pull-request workflow that triggers on label events, builds and pushes a preview image, then posts the comment. The
LABEL: previewinput onpreview-commentensures the comment step is skipped if the workflow was triggered for a different label.