1
0
mirror of synced 2025-12-20 02:19:14 -05:00

new script to add a comment to all open PRs in docs-internal

This commit is contained in:
Sarah Schneider
2021-05-17 15:41:46 -04:00
parent 0235ab938c
commit 805ddfec49
2 changed files with 90 additions and 1 deletions

View File

@@ -95,11 +95,43 @@ async function getContents (owner, repo, ref, path) {
}
}
// https://docs.github.com/en/rest/reference/pulls#list-pull-requests
async function listPulls (owner, repo) {
try {
const { data } = await github.pulls.list({
owner,
repo,
per_page: 100
})
return data
} catch (err) {
console.log(`error listing pulls in ${owner}/${repo}`)
throw (err)
}
}
async function createReviewComment (owner, repo, pullNumber, body) {
try {
const { data } = await github.pulls.createReviewComment({
owner,
repo,
pull_number: pullNumber,
body
})
return data
} catch (err) {
console.log(`error creating a review comment on PR ${pullNumber} in ${owner}/${repo}`)
throw (err)
}
}
module.exports = {
getTree,
getTreeSha,
getCommitSha,
getContentsForBlob,
getContents,
listMatchingRefs
listMatchingRefs,
listPulls,
createReviewComment
}