@@ -231,8 +231,17 @@ export default eventHandler(async (event) => {
231231 ) ;
232232
233233 if ( comment !== "off" ) {
234- await ( comment === "update" && prevComment !
235- ? installation . request (
234+ const { data : { permissions } } = await installation . request (
235+ "GET /repos/{owner}/{repo}/installation" ,
236+ {
237+ owner : workflowData . owner ,
238+ repo : workflowData . repo ,
239+ }
240+ ) ;
241+
242+ try {
243+ if ( comment === "update" && prevComment ! ) {
244+ await installation . request (
236245 "PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}" ,
237246 {
238247 owner : workflowData . owner ,
@@ -250,8 +259,9 @@ export default eventHandler(async (event) => {
250259 "ref" ,
251260 ) ,
252261 } ,
253- )
254- : installation . request (
262+ ) ;
263+ } else {
264+ await installation . request (
255265 "POST /repos/{owner}/{repo}/issues/{issue_number}/comments" ,
256266 {
257267 owner : workflowData . owner ,
@@ -269,7 +279,11 @@ export default eventHandler(async (event) => {
269279 comment === "update" ? "ref" : "sha" ,
270280 ) ,
271281 } ,
272- ) ) ;
282+ ) ;
283+ }
284+ } catch ( e ) {
285+ console . error ( "failed to create/update comment" , e , permissions ) ;
286+ }
273287 }
274288 }
275289
0 commit comments