MCPcopy Create free account
hub / github.com/decaporg/decap-cms / closeIssueOnPublish

Method closeIssueOnPublish

packages/decap-cms-backend-github/src/API.ts:1802–1825  ·  view source on GitHub ↗

* Close the notes issue when an entry is published

(collectionName: string, slug: string)

Source from the content-addressed store, hash-verified

1800 * Close the notes issue when an entry is published
1801 */
1802 async closeIssueOnPublish(collectionName: string, slug: string): Promise<void> {
1803 try {
1804 const searchQuery = `repo:${this.repo} label:${API.NOTES_LABEL} "${collectionName}/${slug}" in:body state:open`;
1805 const searchResponse = await this.request('/search/issues', {
1806 params: { q: searchQuery },
1807 });
1808
1809 if (searchResponse.items && searchResponse.items.length > 0) {
1810 const issue = searchResponse.items[0];
1811 await this.request(`${this.repoURL}/issues/${issue.number}`, {
1812 method: 'PATCH',
1813 body: JSON.stringify({
1814 state: 'closed',
1815 labels: [
1816 ...(issue.labels || []).map((l: { name: string }) => l.name),
1817 'entry-published',
1818 ],
1819 }),
1820 });
1821 }
1822 } catch (error) {
1823 console.warn('Failed to close notes issue on publish:', error);
1824 }
1825 }
1826
1827 /**
1828 * Reopen the notes issue when an entry is unpublished

Callers 2

Calls 2

requestMethod · 0.95
mapMethod · 0.80

Tested by

no test coverage detected