mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-20 06:21:09 +02:00
Update course-schedule PR comments in-place (#1856)
Instead of always adding a new comment, just update the existing comment if one exists. This fixes #1834.
This commit is contained in:
parent
c1e605df25
commit
adff70d025
29
.github/workflows/course-schedule-comment.yml
vendored
29
.github/workflows/course-schedule-comment.yml
vendored
@ -60,9 +60,32 @@ jobs:
|
|||||||
var pr_number = Number(fs.readFileSync('pr-number'));
|
var pr_number = Number(fs.readFileSync('pr-number'));
|
||||||
var upstream = fs.readFileSync('upstream-schedule').toString();
|
var upstream = fs.readFileSync('upstream-schedule').toString();
|
||||||
var schedule = fs.readFileSync('schedule').toString();
|
var schedule = fs.readFileSync('schedule').toString();
|
||||||
if (upstream != schedule) {
|
schedule = "<!-- course-schedule -->\n" +
|
||||||
schedule = schedule + "# New Course Schedule\n";
|
"# Changes to Course Schedule\n" +
|
||||||
schedule = schedule + "This PR changes the course schedule. The new schedule is shown below.";
|
"This PR changes the course schedule. The new schedule is shown below.\n\n" +
|
||||||
|
schedule;
|
||||||
|
|
||||||
|
// Look for existing comments
|
||||||
|
var existing_comment;
|
||||||
|
for await ({ data: comments } of github.paginate.iterator(github.rest.issues.listComments, {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pr_number
|
||||||
|
})) {
|
||||||
|
existing_comment = comments.find((c) => c.body.includes("<!-- course-schedule -->"));
|
||||||
|
if (existing_comment) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existing_comment) {
|
||||||
|
await github.rest.issues.updateComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: existing_comment.id,
|
||||||
|
body: schedule,
|
||||||
|
});
|
||||||
|
} else if (upstream != schedule) {
|
||||||
await github.rest.issues.createComment({
|
await github.rest.issues.createComment({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user