ci: improve pkg.pr.new install comment clarity (#168)

* ci: improve pkg.pr.new install comment clarity

* ci: add emojis to pkg.pr.new install comment headings

* ci: avoid hard fail when PR head metadata is missing

---------

Co-authored-by: kongenpei <kongenpei@users.noreply.github.com>
This commit is contained in:
kongenpei
2026-04-01 11:15:54 +08:00
committed by GitHub
parent bdd39b0196
commit c4851a5c45

View File

@@ -41,13 +41,36 @@ jobs:
if (!url) {
throw new Error("No package URL found in output.json");
}
const sourceRepo = context.payload.pull_request?.head?.repo?.full_name;
const sourceBranch = context.payload.pull_request?.head?.ref;
const hasSkillSource = Boolean(sourceRepo && sourceBranch);
const skillSection = hasSkillSource
? [
"",
"### 🧩 Skill update",
"",
"```bash",
`npx skills add ${sourceRepo}#${sourceBranch} -y -g`,
"```",
]
: [
"",
"### 🧩 Skill update",
"",
"_Unavailable for this PR because source repo/branch metadata is missing._",
];
const body = [
"Install this PR change globally:",
"<!-- pkg-pr-new-install-guide -->",
"## 🚀 PR Preview Install Guide",
"",
"### 🧰 CLI update",
"",
"```bash",
`npm i -g ${url}`,
"```",
...skillSection,
].join("\n");
const issueNumber = context.issue.number;
@@ -61,7 +84,7 @@ jobs:
const existing = comments.find((comment) =>
comment.user?.login === "github-actions[bot]" &&
typeof comment.body === "string" &&
comment.body.startsWith("Install this PR change globally:")
comment.body.includes("<!-- pkg-pr-new-install-guide -->")
);
if (existing) {