File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -144,14 +144,15 @@ _This PR was last updated in response to the \`/run-ci\` command in #${prDetails
144144 });
145145 } else {
146146 // Existing PR found but it's not labeled as a CI test PR
147- // Treat it as a new PR scenario
148- isNewPR = true;
147+ // Use the first one and add the labels
148+ ciPR = existingPRs.data[0];
149+ isNewPR = true; // Treat as new to ensure labels are added
149150 }
150151 }
151152
152- if (isNewPR || existingPRs.data.length === 0 ) {
153+ if (!ciPR ) {
153154 // Create a new draft PR
154- ciPR = await github.rest.pulls.create({
155+ const newPR = await github.rest.pulls.create({
155156 owner : context.repo.owner,
156157 repo : context.repo.repo,
157158 title : ` [CI Test] ${prDetails.title}` ,
@@ -172,11 +173,12 @@ This is an automated PR created to run CI tests for PR #${prDetails.number} by @
172173_This PR was created in response to the \` /run-ci\` command in #${prDetails.number}_` ,
173174 draft : true
174175 });
176+ ciPR = newPR.data;
175177 isNewPR = true;
176178 }
177179
178180 // Ensure labels are present on the CI PR (handles both new and existing PRs)
179- const currentLabels = ciPR.labels?.map(l => l.name) || [];
181+ const currentLabels = ciPR.labels?.map(l => typeof l === 'string' ? l : l.name) || [];
180182 const requiredLabels = ['ci-test', 'automated'];
181183 const missingLabels = requiredLabels.filter(label => !currentLabels.includes(label));
182184
You can’t perform that action at this time.
0 commit comments