Skip to content

Commit

Permalink
build: use existing comment for docs preview links (#2169)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Oct 15, 2019
1 parent 409e395 commit 8110c32
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions build/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,33 @@ export async function postGithubComment() {

octokit.authenticate({ type: 'token', token });

const body = `Preview docs changes for ${SHORT_SHA} at https://previews.ngrx.io/pr${PR_NUMBER}-${SHORT_SHA}/`;

// wait a few seconds for github to settle
await util.sleep(5000);

await octokit.issues.createComment({
const comments: { data: any[] } = await octokit.issues.getComments({
owner,
repo,
number: PR_NUMBER,
body,
});

const ngrxBotComment = comments.data
.filter(comment => comment.user.login === 'ngrxbot')
.pop();

const body = `Preview docs changes for ${SHORT_SHA} at https://previews.ngrx.io/pr${PR_NUMBER}-${SHORT_SHA}/`;

if (ngrxBotComment) {
await octokit.issues.editComment({
owner,
repo,
comment_id: ngrxBotComment.id,
body,
});
} else {
await octokit.issues.createComment({
owner,
repo,
number: PR_NUMBER,
body,
});
}
}
}

Expand Down

0 comments on commit 8110c32

Please sign in to comment.