Skip to content

Commit f91078b

Browse files
authored
add PR template for API-Nodes (Comfy-Org#10736)
1 parent 3b3ef9a commit f91078b

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- API_NODE_PR_CHECKLIST: do not remove -->
2+
3+
## API Node PR Checklist
4+
5+
### Scope
6+
- [ ] **Is API Node Change**
7+
8+
### Pricing & Billing
9+
- [ ] **Need pricing update**
10+
- [ ] **No pricing update**
11+
12+
If **Need pricing update**:
13+
- [ ] Metronome rate cards updated
14+
- [ ] Auto‑billing tests updated and passing
15+
16+
### QA
17+
- [ ] **QA done**
18+
- [ ] **QA not required**
19+
20+
### Comms
21+
- [ ] Informed **@Kosinkadink**
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Append API Node PR template
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, synchronize, edited, ready_for_review]
6+
paths:
7+
- 'comfy_api_nodes/**' # only run if these files changed
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
inject:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Ensure template exists and append to PR body
18+
uses: actions/github-script@v7
19+
with:
20+
script: |
21+
const { owner, repo } = context.repo;
22+
const number = context.payload.pull_request.number;
23+
const templatePath = '.github/PULL_REQUEST_TEMPLATE/api-node.md';
24+
const marker = '<!-- API_NODE_PR_CHECKLIST: do not remove -->';
25+
26+
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number });
27+
28+
let templateText;
29+
try {
30+
const res = await github.rest.repos.getContent({
31+
owner,
32+
repo,
33+
path: templatePath,
34+
ref: pr.base.ref
35+
});
36+
const buf = Buffer.from(res.data.content, res.data.encoding || 'base64');
37+
templateText = buf.toString('utf8');
38+
} catch (e) {
39+
core.setFailed(`Required PR template not found at "${templatePath}" on ${pr.base.ref}. Please add it to the repo.`);
40+
return;
41+
}
42+
43+
// Enforce the presence of the marker inside the template (for idempotence)
44+
if (!templateText.includes(marker)) {
45+
core.setFailed(`Template at "${templatePath}" does not contain the required marker:\n${marker}\nAdd it so we can detect duplicates safely.`);
46+
return;
47+
}
48+
49+
// If the PR already contains the marker, do not append again.
50+
const body = pr.body || '';
51+
if (body.includes(marker)) {
52+
core.info('Template already present in PR body; nothing to inject.');
53+
return;
54+
}
55+
56+
const newBody = (body ? body + '\n\n' : '') + templateText + '\n';
57+
await github.rest.pulls.update({ owner, repo, pull_number: number, body: newBody });
58+
core.notice('API Node template appended to PR description.');

0 commit comments

Comments
 (0)