Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fixes theme preview action #2566

Merged
merged 1 commit into from
Mar 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ci: fixes theme preview action
rickstaa committed Mar 5, 2023
commit ab2a6f6c276154a22502f8d8b733efd8aed6cbb2
44 changes: 33 additions & 11 deletions scripts/preview-theme.js
Original file line number Diff line number Diff line change
@@ -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;
};
@@ -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 = "";