mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-08-20 06:23:30 +00:00
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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user