Skip to content

Commit

Permalink
ci: fixes theme preview action (#2566)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Mar 5, 2023
1 parent 1e61f9f commit ed18914
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions scripts/preview-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,36 @@ const findComment = async (octokit, issueNumber, owner, repo, commenter) => {
* Create or update the preview comment.
*
* @param {Object} octokit Octokit instance.
* @param {Object} props Comment properties.
* @param {number} issueNumber Issue number.
* @param {Object} repo Repository name.
* @param {Object} owner Owner of the repository.
* @param {number} commentId Comment ID.
* @param {string} body Comment body.
* @return {string} The comment URL.
*/
const upsertComment = async (octokit, props) => {
const upsertComment = async (
octokit,
issueNumber,
repo,
owner,
commentId,
body,
) => {
let resp;
if (props.comment_id !== undefined) {
resp = await octokit.issues.updateComment(props);
if (commentId !== undefined) {
resp = await octokit.issues.updateComment({
owner,
repo,
comment_id: commentId,
body,
});
} else {
resp = await octokit.issues.createComment(props);
resp = await octokit.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body,
});
}
return resp.data.html_url;
};
Expand Down Expand Up @@ -539,13 +560,14 @@ export const run = async () => {
debug("Create or update theme-preview comment...");
let comment_url;
if (!DRY_RUN) {
comment_url = await upsertComment(OCTOKIT, {
comment_id: comment?.id,
issue_number: PULL_REQUEST_ID,
OWNER,
comment_url = await upsertComment(
OCTOKIT,
PULL_REQUEST_ID,
REPO,
body: commentBody,
});
OWNER,
comment?.id,
commentBody,
);
} else {
info(`DRY_RUN: Comment body: ${commentBody}`);
comment_url = "";
Expand Down

0 comments on commit ed18914

Please sign in to comment.