Preview theme workflow fix (#2557)
* Fix octokit error * ci: make octokit instance global --------- Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
1 parent
d60d53cdb4
commit
8849b5f5fc
1 file changed
+10
-8
@@ -44,6 +44,9 @@ const REQUIRED_COLOR_PROPS = ACCEPTED_COLOR_PROPS.slice(0, 4);
|
|||||||
const INVALID_REVIEW_COMMENT = (commentUrl) =>
|
const INVALID_REVIEW_COMMENT = (commentUrl) =>
|
||||||
`Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`;
|
`Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`;
|
||||||
|
|
||||||
|
// Retrieve octokit instance.
|
||||||
|
const OCTOKIT = github.getOctokit(getGithubToken());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve PR number from the event payload.
|
* Retrieve PR number from the event payload.
|
||||||
*
|
*
|
||||||
@@ -312,7 +315,6 @@ export const run = async (prNumber) => {
|
|||||||
\r${THEME_CONTRIB_GUIDELINESS}
|
\r${THEME_CONTRIB_GUIDELINESS}
|
||||||
`;
|
`;
|
||||||
const ccc = new ColorContrastChecker();
|
const ccc = new ColorContrastChecker();
|
||||||
const octokit = github.getOctokit(getGithubToken());
|
|
||||||
const pullRequestId = prNumber ? prNumber : getPrNumber();
|
const pullRequestId = prNumber ? prNumber : getPrNumber();
|
||||||
const commenter = getCommenter();
|
const commenter = getCommenter();
|
||||||
const { owner, repo } = getRepoInfo(github.context);
|
const { owner, repo } = getRepoInfo(github.context);
|
||||||
@@ -322,7 +324,7 @@ export const run = async (prNumber) => {
|
|||||||
|
|
||||||
// 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: pullRequestId,
|
||||||
@@ -332,7 +334,7 @@ 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,
|
pullRequestId,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -515,7 +517,7 @@ export const run = async (prNumber) => {
|
|||||||
debug("Create or update theme-preview comment...");
|
debug("Create or update theme-preview comment...");
|
||||||
let comment_url;
|
let comment_url;
|
||||||
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: pullRequestId,
|
||||||
owner,
|
owner,
|
||||||
@@ -538,7 +540,7 @@ export const run = async (prNumber) => {
|
|||||||
: INVALID_REVIEW_COMMENT(comment_url);
|
: INVALID_REVIEW_COMMENT(comment_url);
|
||||||
if (!DRY_RUN) {
|
if (!DRY_RUN) {
|
||||||
await addReview(
|
await addReview(
|
||||||
octokit,
|
OCTOKIT,
|
||||||
pullRequestId,
|
pullRequestId,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -546,7 +548,7 @@ export const run = async (prNumber) => {
|
|||||||
reviewReason,
|
reviewReason,
|
||||||
);
|
);
|
||||||
await addRemoveLabel(
|
await addRemoveLabel(
|
||||||
octokit,
|
OCTOKIT,
|
||||||
pullRequestId,
|
pullRequestId,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -561,7 +563,7 @@ export const run = async (prNumber) => {
|
|||||||
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
|
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
|
||||||
if (!DRY_RUN) {
|
if (!DRY_RUN) {
|
||||||
await addReview(
|
await addReview(
|
||||||
octokit,
|
OCTOKIT,
|
||||||
pullRequestId,
|
pullRequestId,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -569,7 +571,7 @@ export const run = async (prNumber) => {
|
|||||||
error.message,
|
error.message,
|
||||||
);
|
);
|
||||||
await addRemoveLabel(
|
await addRemoveLabel(
|
||||||
octokit,
|
OCTOKIT,
|
||||||
pullRequestId,
|
pullRequestId,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
|
|||||||
Reference in new issue
Block a user