Skip to content

Commit 44201b4

Browse files
Merge pull request #118 from stuttgart-things/feat/116-bot-via-reusable
ci(preview): swap inline bot comment for reusable workflow
2 parents 6bf8c2a + cc4f28b commit 44201b4

1 file changed

Lines changed: 6 additions & 48 deletions

File tree

.github/workflows/comment-preview-url.yaml

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,11 @@ on:
66
branches:
77
- main
88

9-
permissions:
10-
pull-requests: write
11-
129
jobs:
1310
comment:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/github-script@v7
17-
with:
18-
script: |
19-
const num = context.issue.number;
20-
const url = `https://omni-pr-${num}.homerun2-dev.sthings-vsphere.labul.sva.de`;
21-
const marker = "<!-- preview-url-bot -->";
22-
const body = [
23-
marker,
24-
"## 🚀 Preview environment",
25-
"",
26-
`| | |`,
27-
`|--|--|`,
28-
`| URL | ${url} |`,
29-
`| Health | ${url}/health |`,
30-
`| Namespace | \`homerun2-pr-${num}\` on \`homerun2-dev\` |`,
31-
`| ArgoCD | [\`homerun2-pr-${num}\`](https://argocd.platform.sthings-vsphere.labul.sva.de/applications?search=homerun2-pr-${num}) |`,
32-
"",
33-
"Spinning up — give it a couple of minutes for image + kustomize OCI builds to publish and for ArgoCD to sync.",
34-
"Closing this PR tears the preview down automatically.",
35-
].join("\n");
36-
37-
// Sticky comment: update on reopen instead of stacking duplicates.
38-
const { data: comments } = await github.rest.issues.listComments({
39-
owner: context.repo.owner,
40-
repo: context.repo.repo,
41-
issue_number: num,
42-
});
43-
const existing = comments.find(c => c.body && c.body.includes(marker));
44-
if (existing) {
45-
await github.rest.issues.updateComment({
46-
owner: context.repo.owner,
47-
repo: context.repo.repo,
48-
comment_id: existing.id,
49-
body,
50-
});
51-
} else {
52-
await github.rest.issues.createComment({
53-
owner: context.repo.owner,
54-
repo: context.repo.repo,
55-
issue_number: num,
56-
body,
57-
});
58-
}
11+
uses: stuttgart-things/github-workflow-templates/.github/workflows/call-comment-preview-url.yaml@main
12+
with:
13+
hostname-prefix: omni-pr
14+
hostname-domain: homerun2-dev.sthings-vsphere.labul.sva.de
15+
namespace-prefix: homerun2-pr
16+
secrets: inherit # pragma: allowlist secret

0 commit comments

Comments
 (0)