mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat: link commit in check suite messages
Add clickable commit links in check_suite formatter output with fallback URL when html_url is unavailable. Remove check_run from checks template since formatter only handles check_suite events.
This commit is contained in:
parent
5deff66b8d
commit
55eafaeecc
3 changed files with 14 additions and 4 deletions
|
|
@ -82,7 +82,7 @@ export const ROUTE_TEMPLATES: RouteTemplate[] = [
|
|||
{
|
||||
id: "checks",
|
||||
nameKey: "templates.checks",
|
||||
filters: [{ type: "event", match: ["check_suite", "check_run"] }],
|
||||
filters: [{ type: "event", match: ["check_suite"] }],
|
||||
},
|
||||
{
|
||||
id: "deployments",
|
||||
|
|
|
|||
|
|
@ -164,10 +164,13 @@ describe("message title spec", () => {
|
|||
event("check_suite", { check_suite: suite, repository: repo, sender }),
|
||||
);
|
||||
expect(msg.title).toBe("acme/widget: Check suite success");
|
||||
expect(msg.url).toBe("https://github.com/acme/widget/runs/2");
|
||||
expect(msg.fields![0].value).toBe("✅ success");
|
||||
expect(msg.fields![1].value).toBe("Cloudflare Pages");
|
||||
expect(msg.fields![2].value).toBe("main");
|
||||
expect(msg.fields![3].value).toBe("abc123d");
|
||||
expect(msg.fields![3].value).toBe(
|
||||
"[abc123d](https://github.com/acme/widget/commit/abc123def456)",
|
||||
);
|
||||
});
|
||||
|
||||
it("workflow_job shows job status, workflow, branch and commit", () => {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,10 @@ export function formatCheckSuite(
|
|||
if (suite.head_sha) {
|
||||
fields.push({
|
||||
name: t("fields.commit"),
|
||||
value: suite.head_sha.slice(0, 7),
|
||||
value:
|
||||
repo && suite.head_sha
|
||||
? `[${suite.head_sha.slice(0, 7)}](https://github.com/${repo}/commit/${suite.head_sha})`
|
||||
: `\`${suite.head_sha.slice(0, 7)}\``,
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -72,7 +75,11 @@ export function formatCheckSuite(
|
|||
repo: repo ?? t("common.repository"),
|
||||
conclusion: status,
|
||||
}),
|
||||
url: suite.html_url,
|
||||
url:
|
||||
suite.html_url ??
|
||||
(repo && suite.head_sha
|
||||
? `https://github.com/${repo}/commit/${suite.head_sha}/checks`
|
||||
: undefined),
|
||||
color: GITHUB_COLORS[colorKey],
|
||||
fields,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue