Skip to content

Commit 72c3b8f

Browse files
authored
Update classroom.yml
1 parent fd028d5 commit 72c3b8f

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

.github/workflows/classroom.yml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,39 +160,37 @@ jobs:
160160
echo "$FEEDBACK_CONTENT" >> $GITHUB_OUTPUT
161161
echo "EOF" >> $GITHUB_OUTPUT
162162
163-
# 💬 Post Feedback
164163
- name: Post Feedback as PR Comment ✍️
165164
uses: actions/github-script@v7
166165
env:
167166
FEEDBACK_BODY: ${{ steps.ai_feedback.outputs.feedback }}
168167
with:
169168
github-token: ${{ secrets.GITHUB_TOKEN }}
170169
script: |
171-
const signature = "";
172-
const body = `${process.env.FEEDBACK_BODY}\n\n${signature}`;
173170
const { owner, repo } = context.repo;
174-
const issue_number = context.issue.number;
171+
const branchName = "feedback";
175172
176-
const { data: comments } = await github.rest.issues.listComments({
173+
// Find the open PR for the feedback branch
174+
const { data: pullRequests } = await github.rest.pulls.list({
177175
owner,
178176
repo,
179-
issue_number,
177+
head: `${owner}:${branchName}`,
178+
state: "open"
180179
});
181180
182-
const previousComment = comments.find(comment => comment.body.includes(signature));
183-
184-
if (previousComment) {
185-
await github.rest.issues.updateComment({
186-
owner,
187-
repo,
188-
comment_id: previousComment.id,
189-
body,
190-
});
191-
} else {
192-
await github.rest.issues.createComment({
193-
owner,
194-
repo,
195-
issue_number,
196-
body,
197-
});
181+
if (pullRequests.length === 0) {
182+
throw new Error(`No open pull request found for branch '${branchName}'`);
198183
}
184+
185+
const prNumber = pullRequests[0].number;
186+
const timestamp = new Date().toISOString();
187+
const body = `### 🤖 AI Feedback\n\n${process.env.FEEDBACK_BODY}\n\n---\n🕒 _Posted on ${timestamp}_`;
188+
189+
await github.rest.issues.createComment({
190+
owner,
191+
repo,
192+
issue_number: prNumber,
193+
body
194+
});
195+
196+
console.log(`✅ Posted new feedback to PR #${prNumber}`);

0 commit comments

Comments
 (0)