ci: add stale theme pull request closer action push (#2067)

This commit adds the `stale-theme-pr-closer` closer action. This action
is used to close theme pull requests with an `invalid` label that has
been stale for a given number of `STALE_DAYS`.
This commit is contained in:
Rick Staa
2022-10-02 11:05:13 +02:00
committed by GitHub
parent 986070a597
commit b8faef6857
10 changed files with 242 additions and 43 deletions
+3 -37
View File
@@ -4,7 +4,7 @@
import * as dotenv from "dotenv";
dotenv.config();
import core, { debug, setFailed } from "@actions/core";
import { debug, setFailed } from "@actions/core";
import github from "@actions/github";
import ColorContrastChecker from "color-contrast-checker";
import { info } from "console";
@@ -14,10 +14,9 @@ import parse from "parse-diff";
import { inspect } from "util";
import { isValidHexColor } from "../src/common/utils.js";
import { themes } from "../themes/index.js";
import { getGithubToken, getRepoInfo } from "./helpers.js";
// Script variables
const OWNER = "anuraghazra";
const REPO = "github-readme-stats";
// Script variables.
const COMMENTER = "github-actions[bot]";
const COMMENT_TITLE = "Automated Theme Preview";
@@ -43,26 +42,6 @@ const REQUIRED_COLOR_PROPS = [
const INVALID_REVIEW_COMMENT = (commentUrl) =>
`Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`;
/**
* Retrieve information about the repository that ran the action.
*
* @param {Object} context Action context.
* @returns {Object} Repository information.
*/
export const getRepoInfo = (ctx) => {
try {
return {
owner: ctx.repo.owner,
repo: ctx.repo.repo,
};
} catch (error) {
return {
owner: OWNER,
repo: REPO,
};
}
};
/**
* Retrieve PR number from the event payload.
*
@@ -86,19 +65,6 @@ const getCommenter = () => {
return process.env.COMMENTER ? process.env.COMMENTER : COMMENTER;
};
/**
* Retrieve github token and throw error if it is not found.
*
* @returns {string} Github token.
*/
const getGithubToken = () => {
const token = core.getInput("github_token") || process.env.GITHUB_TOKEN;
if (!token) {
throw Error("Could not find github token");
}
return token;
};
/**
* Returns whether the comment is a preview comment.
*