Skip to content

Commit 42baac1

Browse files
committed
use a regular issue comment instead of a PR review comment
1 parent 1001502 commit 42baac1

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env node
22

3-
const { listPulls, createReviewComment } = require('../helpers/git-utils')
3+
const { listPulls, createIssueComment } = require('../helpers/git-utils')
44

55
// [start-readme]
66
//
77
// This script finds all open PRs from active branches that touch content files, and adds a comment
8-
// with a prompt to enter a slash command and update files. The idea is to help writers and other Hubbers
9-
// update their open branches and mitigate conflicts with the main branch.
8+
// with steps to run some commands. The idea is to help writers and other Hubbers update their
9+
// open branches and mitigate conflicts with the main branch.
1010
//
1111
// [end-readme]
1212

@@ -22,21 +22,18 @@ const options = {
2222
}
2323

2424
const comment = `
25-
Hello! The docs-engineering team has just published an update that touches all content files in the repo. To reduce conflicts with \`main\`, we wanted to offer a programmatic option to update your branch.
25+
👋 Hello! The docs-engineering team has just published an update that touches all content files in the repo. To reduce conflicts with \`main\`, we are sending out this message to help folks update their branches.
2626
27-
To take advantage of this option, in a new comment on this PR, type and enter: \`/update-content-in-branch\`.
27+
You'll need to do the following steps in Terminal. If you're not into that, ask in #docs-engineering and we'll help out!
2828
29-
This is a custom slash command that will trigger a GitHub Action workflow to do the following:
29+
1. Check out the branch associated with this PR. Don't update from \`main\` yet.
30+
2. Run: \`script/content-migrations/remove-map-topics.js && script/content-migrations/update-tocs.js\`
31+
3. Commit: \`git add . && git commit -m 'ran content migration scripts'\`
32+
4. Update: \`git pull origin main\`
3033
31-
1. Check out your branch.
32-
2. Run some special scripts.
33-
3. Commit and push the results back to your branch.
34+
You may still have some conflicts to resolve. Feel free to ask us if you have questions or need help!
3435
35-
Once that's done, you can update from \`main\`. You may still have some conflicts to resolve.
36-
37-
Feel free to ask if you have questions or need help!
38-
39-
For a 5min demo of what the scripts do and why they're needed, check out https://www.loom.com/share/fa6501580b2a44d7a8a4357ee51e0c99.
36+
For a 5min demo of what the scripts do and why they're needed, check out [this screencast](https://www.loom.com/share/fa6501580b2a44d7a8a4357ee51e0c99).
4037
`
4138

4239
main()
@@ -51,7 +48,7 @@ async function main () {
5148

5249
// for every open PR, create a review comment
5350
await Promise.all(openPullNumbers.map(async (pullNumber) => {
54-
await createReviewComment(options.owner, options.repo, pullNumber, comment)
55-
console.log(`added a comment to PR #${pullNumber}`)
51+
await createIssueComment(options.owner, options.repo, pullNumber, comment)
52+
console.log(`Added a comment to PR #${pullNumber}`)
5653
}))
5754
}

script/helpers/git-utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ async function listPulls (owner, repo) {
110110
}
111111
}
112112

113-
async function createReviewComment (owner, repo, pullNumber, body) {
113+
async function createIssueComment (owner, repo, pullNumber, body) {
114114
try {
115-
const { data } = await github.pulls.createReviewComment({
115+
const { data } = await github.issues.createComment({
116116
owner,
117117
repo,
118-
pull_number: pullNumber,
118+
issue_number: pullNumber,
119119
body
120120
})
121121
return data
@@ -133,5 +133,5 @@ module.exports = {
133133
getContents,
134134
listMatchingRefs,
135135
listPulls,
136-
createReviewComment
136+
createIssueComment
137137
}

script/helpers/github.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ if (!process.env.GITHUB_TOKEN) {
1010
// 3. an installation token granted via GitHub Actions
1111
const apiToken = process.env.GITHUB_TOKEN
1212

13+
const { Octokit } = require('@octokit/rest')
14+
1315
// See https://github.com/octokit/rest.js/issues/1207
1416
module.exports = function github () {
15-
return require('@octokit/rest')({
17+
return new Octokit({
1618
auth: `token ${apiToken}`
1719
})
1820
}

0 commit comments

Comments
 (0)