Files
changesets-action/dist/pr-comment.js
T

1 line
1001 B
JavaScript

import{A as e,T as t,j as n,k as r,o as i,s as a,w as o}from"./utils-CAuP846_.js";try{await s()}catch(t){e(t.message)}async function s(){let e=o.payload.pull_request;if(!e)throw Error("This action should only be run on `pull_request_target` or `pull_request` events");let s=a(`github-token`),l=a(`body`),u=i(`update-id`),d=u?c(u):null,f=d?`${d}\n\n${l}`:l,p={repo:e.base.repo.name,owner:e.base.repo.owner.login,issue_number:e.number,body:f},m=t(s),h;if(d&&(r(`Checking for existing comment...`),h=await m.rest.issues.listComments({repo:e.base.repo.name,owner:e.base.repo.owner.login,issue_number:e.number}).then(e=>e.data.find(e=>e.body?.includes(d))?.id)),h)r(`Updating existing comment (id: ${h})...`),await m.rest.issues.updateComment({...p,comment_id:h}),n(`comment-id`,h);else{r(`Creating new comment...`);let e=await m.rest.issues.createComment(p);n(`comment-id`,e.data.id)}r(`Done!`)}function c(e){let t=`changesets-action-pr-comment`;return t===e?`<!-- ${t} -->`:`<!-- ${t}:${e} -->`}export{};