@@ -159,7 +159,6 @@ jobs:
159159 echo "feedback<<EOF" >> $GITHUB_OUTPUT
160160 echo "$FEEDBACK_CONTENT" >> $GITHUB_OUTPUT
161161 echo "EOF" >> $GITHUB_OUTPUT
162-
163162 - name : Post Feedback as PR Comment ✍️
164163 uses : actions/github-script@v7
165164 env :
@@ -168,21 +167,23 @@ jobs:
168167 github-token : ${{ secrets.GITHUB_TOKEN }}
169168 script : |
170169 const { owner, repo } = context.repo;
171- const branchName = "feedback ";
170+ const targetTitle = "Feedback ";
172171
173- // Find the open PR for the feedback branch
172+ // List all open PRs
174173 const { data: pullRequests } = await github.rest.pulls.list({
175174 owner,
176175 repo,
177- head: `${owner}:${branchName}` ,
178- state: "open"
176+ state: "open" ,
177+ per_page: 100
179178 });
180179
181- if (pullRequests.length === 0) {
182- throw new Error(`No open pull request found for branch '${branchName}'`);
180+ const matchingPR = pullRequests.find(pr => pr.title.trim().toLowerCase() === targetTitle.toLowerCase());
181+
182+ if (!matchingPR) {
183+ throw new Error(`No open pull request found with title '${targetTitle}'`);
183184 }
184185
185- const prNumber = pullRequests[0] .number;
186+ const prNumber = matchingPR .number;
186187 const timestamp = new Date().toISOString();
187188 const body = `### 🤖 AI Feedback\n\n${process.env.FEEDBACK_BODY}\n\n---\n🕒 _Posted on ${timestamp}_`;
188189
@@ -193,4 +194,4 @@ jobs:
193194 body
194195 });
195196
196- console.log(`✅ Posted new feedback to PR #${prNumber}`);
197+ console.log(`✅ Posted feedback to PR #${prNumber} titled '${targetTitle}' `);
0 commit comments