ci: preview theme workflow fix (#2559)
* Fix octokit error * ci: make octokit instance global * Fix preview theme (move declarations to global) * refactor: make constants uppercase --------- Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
1 parent
8849b5f5fc
commit
a1c3c6accc
1 file changed
+25
-25
+25
-25
@@ -46,6 +46,8 @@ const INVALID_REVIEW_COMMENT = (commentUrl) =>
|
|||||||
|
|
||||||
// Retrieve octokit instance.
|
// Retrieve octokit instance.
|
||||||
const OCTOKIT = github.getOctokit(getGithubToken());
|
const OCTOKIT = github.getOctokit(getGithubToken());
|
||||||
|
const PULL_REQUEST_ID = prNumber ? prNumber : getPrNumber();
|
||||||
|
const { OWNER, REPO } = getRepoInfo(github.context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve PR number from the event payload.
|
* Retrieve PR number from the event payload.
|
||||||
@@ -315,19 +317,17 @@ export const run = async (prNumber) => {
|
|||||||
\r${THEME_CONTRIB_GUIDELINESS}
|
\r${THEME_CONTRIB_GUIDELINESS}
|
||||||
`;
|
`;
|
||||||
const ccc = new ColorContrastChecker();
|
const ccc = new ColorContrastChecker();
|
||||||
const pullRequestId = prNumber ? prNumber : getPrNumber();
|
|
||||||
const commenter = getCommenter();
|
const commenter = getCommenter();
|
||||||
const { owner, repo } = getRepoInfo(github.context);
|
debug(`Owner: ${OWNER}`);
|
||||||
debug(`Owner: ${owner}`);
|
debug(`Repo: ${REPO}`);
|
||||||
debug(`Repo: ${repo}`);
|
|
||||||
debug(`Commenter: ${commenter}`);
|
debug(`Commenter: ${commenter}`);
|
||||||
|
|
||||||
// Retrieve the PR diff and preview-theme comment.
|
// Retrieve the PR diff and preview-theme comment.
|
||||||
debug("Retrieve PR diff...");
|
debug("Retrieve PR diff...");
|
||||||
const res = await OCTOKIT.pulls.get({
|
const res = await OCTOKIT.pulls.get({
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
pull_number: pullRequestId,
|
pull_number: PULL_REQUEST_ID,
|
||||||
mediaType: {
|
mediaType: {
|
||||||
format: "diff",
|
format: "diff",
|
||||||
},
|
},
|
||||||
@@ -335,9 +335,9 @@ export const run = async (prNumber) => {
|
|||||||
debug("Retrieve preview-theme comment...");
|
debug("Retrieve preview-theme comment...");
|
||||||
const comment = await findComment(
|
const comment = await findComment(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
pullRequestId,
|
PULL_REQUEST_ID,
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
commenter,
|
commenter,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -519,9 +519,9 @@ export const run = async (prNumber) => {
|
|||||||
if (!DRY_RUN) {
|
if (!DRY_RUN) {
|
||||||
comment_url = await upsertComment(OCTOKIT, {
|
comment_url = await upsertComment(OCTOKIT, {
|
||||||
comment_id: comment?.id,
|
comment_id: comment?.id,
|
||||||
issue_number: pullRequestId,
|
issue_number: PULL_REQUEST_ID,
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
body: commentBody,
|
body: commentBody,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -541,17 +541,17 @@ export const run = async (prNumber) => {
|
|||||||
if (!DRY_RUN) {
|
if (!DRY_RUN) {
|
||||||
await addReview(
|
await addReview(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
pullRequestId,
|
PULL_REQUEST_ID,
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
reviewState,
|
reviewState,
|
||||||
reviewReason,
|
reviewReason,
|
||||||
);
|
);
|
||||||
await addRemoveLabel(
|
await addRemoveLabel(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
pullRequestId,
|
PULL_REQUEST_ID,
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
"invalid",
|
"invalid",
|
||||||
!themesValid,
|
!themesValid,
|
||||||
);
|
);
|
||||||
@@ -564,17 +564,17 @@ export const run = async (prNumber) => {
|
|||||||
if (!DRY_RUN) {
|
if (!DRY_RUN) {
|
||||||
await addReview(
|
await addReview(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
pullRequestId,
|
PULL_REQUEST_ID,
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
"REQUEST_CHANGES",
|
"REQUEST_CHANGES",
|
||||||
error.message,
|
error.message,
|
||||||
);
|
);
|
||||||
await addRemoveLabel(
|
await addRemoveLabel(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
pullRequestId,
|
PULL_REQUEST_ID,
|
||||||
owner,
|
OWNER,
|
||||||
repo,
|
REPO,
|
||||||
"invalid",
|
"invalid",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user