MCPcopy Create free account
hub / github.com/github/gh-aw / createOrUpdateIssue

Function createOrUpdateIssue

actions/setup/js/missing_issue_helpers.cjs:68–169  ·  view source on GitHub ↗

* Create or update an issue for the missing items * @param {string} workflowName - Name of the workflow * @param {string} workflowSource - Source path of the workflow * @param {string} workflowSourceURL - URL to the workflow source * @param {string} runUrl - URL to the workflow r

(workflowName, workflowSource, workflowSourceURL, runUrl, items)

Source from the content-addressed store, hash-verified

66 * @returns {Promise<Object>} Result with success/error status
67 */
68 async function createOrUpdateIssue(workflowName, workflowSource, workflowSourceURL, runUrl, items) {
69 const { owner, repo } = context.repo;
70
71 // Create issue title
72 const issueTitle = `${titlePrefix} ${workflowName}`;
73
74 core.info(`Checking for existing issue with title: "${issueTitle}"`);
75
76 // Search for existing open issue with this title
77 const searchQuery = `repo:${owner}/${repo} is:issue is:open in:title "${issueTitle}"`;
78
79 try {
80 const searchResult = await github.rest.search.issuesAndPullRequests({
81 q: searchQuery,
82 per_page: 1,
83 });
84
85 if (searchResult.data.total_count > 0) {
86 // Issue exists, add a comment
87 const existingIssue = searchResult.data.items[0];
88 core.info(`Found existing issue #${existingIssue.number}: ${existingIssue.html_url}`);
89
90 // Build comment body
91 const commentLines = buildCommentHeader(runUrl);
92 items.forEach((item, index) => {
93 commentLines.push(...renderCommentItem(item, index));
94 });
95 commentLines.push(`---`);
96 commentLines.push(`> Workflow: [${workflowName}](${workflowSourceURL})`);
97 commentLines.push(`> Run: ${runUrl}`);
98
99 const commentBody = sanitizeContent(commentLines.join("\n"));
100
101 await github.rest.issues.createComment({
102 owner,
103 repo,
104 issue_number: existingIssue.number,
105 body: commentBody,
106 });
107
108 core.info(`✓ Added comment to existing issue #${existingIssue.number}`);
109
110 return {
111 success: true,
112 issue_number: existingIssue.number,
113 issue_url: existingIssue.html_url,
114 action: "updated",
115 };
116 } else {
117 // No existing issue, create a new one
118 core.info("No existing issue found, creating a new one");
119
120 // Build items list for template
121 const issueListLines = [];
122 items.forEach((item, index) => {
123 issueListLines.push(...renderIssueItem(item, index));
124 });
125

Callers 1

buildMissingIssueHandlerFunction · 0.85

Calls 4

sanitizeContentFunction · 0.85
renderTemplateFromFileFunction · 0.85
getErrorMessageFunction · 0.70

Tested by

no test coverage detected