@@ -36,8 +36,6 @@ export const codeReview = async (
36
36
inputs . title = context . payload . pull_request . title
37
37
if ( context . payload . pull_request . body ) {
38
38
inputs . description = context . payload . pull_request . body
39
- } else {
40
- inputs . description = context . payload . pull_request . title
41
39
}
42
40
43
41
// collect diff chunks
@@ -231,47 +229,47 @@ export const codeReview = async (
231
229
'<!-- This is an auto-generated comment: release notes by chatgpt -->'
232
230
const tag_end =
233
231
'<!-- end of auto-generated comment: release notes by chatgpt -->'
234
- // get the description of the PR
235
- const { data : pr } = await octokit . pulls . get ( {
236
- owner : repo . owner ,
237
- repo : repo . repo ,
238
- pull_number : context . payload . pull_request . number
239
- } )
240
- let description = ''
241
- if ( pr . body ) {
242
- description = pr . body
243
- }
244
- // find the tag in the description and replace the content between the tag and the tag_end
245
- // if not found, add the tag and the content to the end of the description
246
- const tag_index = description . indexOf ( tag )
247
- const tag_end_index = description . indexOf ( tag_end )
248
- if ( tag_index === - 1 || tag_end_index === - 1 ) {
249
- let new_description = description
250
- new_description += tag
251
- new_description += '\n### Summary by ChatGPT\n'
252
- new_description += release_notes_response
253
- new_description += '\n'
254
- new_description += tag_end
255
- await octokit . pulls . update ( {
256
- owner : repo . owner ,
257
- repo : repo . repo ,
258
- pull_number : context . payload . pull_request . number ,
259
- body : new_description
260
- } )
261
- } else {
262
- let new_description = description . substring ( 0 , tag_index )
263
- new_description += tag
264
- new_description += '\n### Summary by ChatGPT\n'
265
- new_description += release_notes_response
266
- new_description += '\n'
267
- new_description += tag_end
268
- new_description += description . substring ( tag_end_index + tag_end . length )
269
- await octokit . pulls . update ( {
270
- owner : repo . owner ,
271
- repo : repo . repo ,
272
- pull_number : context . payload . pull_request . number ,
273
- body : new_description
274
- } )
232
+ try {
233
+ const description = inputs . description
234
+
235
+ // find the tag in the description and replace the content between the tag and the tag_end
236
+ // if not found, add the tag and the content to the end of the description
237
+ const tag_index = description . indexOf ( tag )
238
+ const tag_end_index = description . indexOf ( tag_end )
239
+ if ( tag_index === - 1 || tag_end_index === - 1 ) {
240
+ let new_description = description
241
+ new_description += tag
242
+ new_description += '\n### Summary by ChatGPT\n'
243
+ new_description += release_notes_response
244
+ new_description += '\n'
245
+ new_description += tag_end
246
+ await octokit . pulls . update ( {
247
+ owner : repo . owner ,
248
+ repo : repo . repo ,
249
+ pull_number : context . payload . pull_request . number ,
250
+ body : new_description
251
+ } )
252
+ } else {
253
+ let new_description = description . substring ( 0 , tag_index )
254
+ new_description += tag
255
+ new_description += '\n### Summary by ChatGPT\n'
256
+ new_description += release_notes_response
257
+ new_description += '\n'
258
+ new_description += tag_end
259
+ new_description += description . substring (
260
+ tag_end_index + tag_end . length
261
+ )
262
+ await octokit . pulls . update ( {
263
+ owner : repo . owner ,
264
+ repo : repo . repo ,
265
+ pull_number : context . payload . pull_request . number ,
266
+ body : new_description
267
+ } )
268
+ }
269
+ } catch ( e : any ) {
270
+ core . warning (
271
+ `Failed to get PR: ${ e } , skipping adding release notes to description.`
272
+ )
275
273
}
276
274
}
277
275
}
0 commit comments