Skip to content

Commit 9b79d05

Browse files
authored
fix: duplicate pr text (#281)
1 parent 3519b91 commit 9b79d05

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

dist/index.js

Lines changed: 7 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@ async function action(): Promise<void> {
2020
return
2121
}
2222

23-
// Authenticate Octokit client
24-
const octokit = getOctokit(token)
25-
26-
// Get pull request using the GitHub context
27-
const {data: pullRequest} = await octokit.rest.pulls.get({
28-
owner: context.repo.owner,
29-
repo: context.repo.repo,
30-
pull_number: context.payload.number
31-
})
23+
// Get PR body from GitHub context (previously using octokit)
24+
const body = context.payload.pull_request?.body || ''
3225

3326
// Note: Any of these checks can work
3427
// body.includes(markdown)
@@ -37,14 +30,14 @@ async function action(): Promise<void> {
3730
// !~body.indexOf(markdown)
3831
// !~body.search(markdown)
3932

40-
// Exit/return if our markdown message is already present
41-
const body = pullRequest.body || ''
33+
// If message is already present, then return/exit
4234
if (body.endsWith(markdown)) {
4335
info('Markdown message is already present. Exiting.')
4436
return
4537
}
4638

47-
// If we're here update the body
39+
// If not present, then append
40+
const octokit = getOctokit(token)
4841
if (!body.endsWith(markdown)) {
4942
info('Description is being updated.')
5043
await octokit.rest.pulls.update({
@@ -57,7 +50,7 @@ async function action(): Promise<void> {
5750
return
5851
}
5952

60-
// If here, something went wrong ...which seems to happen a lot
53+
// If here, kick up an error
6154
error('Unexpected result. Please verify the action has performed correctly.')
6255
}
6356

0 commit comments

Comments
 (0)