@@ -20,15 +20,8 @@ async function action(): Promise<void> {
20
20
return
21
21
}
22
22
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 || ''
32
25
33
26
// Note: Any of these checks can work
34
27
// body.includes(markdown)
@@ -37,14 +30,14 @@ async function action(): Promise<void> {
37
30
// !~body.indexOf(markdown)
38
31
// !~body.search(markdown)
39
32
40
- // Exit/return if our markdown message is already present
41
- const body = pullRequest . body || ''
33
+ // If message is already present, then return/exit
42
34
if ( body . endsWith ( markdown ) ) {
43
35
info ( 'Markdown message is already present. Exiting.' )
44
36
return
45
37
}
46
38
47
- // If we're here update the body
39
+ // If not present, then append
40
+ const octokit = getOctokit ( token )
48
41
if ( ! body . endsWith ( markdown ) ) {
49
42
info ( 'Description is being updated.' )
50
43
await octokit . rest . pulls . update ( {
@@ -57,7 +50,7 @@ async function action(): Promise<void> {
57
50
return
58
51
}
59
52
60
- // If here, something went wrong ...which seems to happen a lot
53
+ // If here, kick up an error
61
54
error ( 'Unexpected result. Please verify the action has performed correctly.' )
62
55
}
63
56
0 commit comments