chore(workflow): close issue if not found, add v1/v2 route tag

This commit is contained in:
NeverBehave
2022-05-16 02:58:54 -07:00
parent e787d2a50e
commit 768a51f266

View File

@@ -8,6 +8,8 @@ const maintainerURL = 'https://raw.githubusercontent.com/DIYgod/RSSHub/gh-pages/
const successTag = 'Bug Ping: Pinged';
const parseFailure = 'Bug Ping: Parse Failure';
const failTag = 'Bug Ping: Not Found';
const v1route = 'Route: v1';
const v2route = 'Route: v2';
const ignoreUsername = new Set([]); // Wrap user who don't want to be pinged.
async function parseBodyRoutes(body, core) {
@@ -82,6 +84,8 @@ module.exports = async ({ github, context, core }) => {
const maintainers = await getMaintainersByRoutes(routes, core);
let successCount = 0;
let emptyCount = 0;
let failedCount = 0;
let comments = '##### Trying to find maintainers: \n\n';
for (let i = 0; i < routes.length; i++) {
@@ -89,12 +93,13 @@ module.exports = async ({ github, context, core }) => {
const main = maintainers[i];
if (main === undefined) {
comments += `- \`${route}\`: **Not found in list**\n`;
failedCount += 1;
continue;
}
if (main.length === 0) {
comments += `- \`${route}\`: No maintainer listed, possibly v1 route or misconfigure\n`;
successCount += 1;
emptyCount += 1;
continue;
}
@@ -112,6 +117,32 @@ module.exports = async ({ github, context, core }) => {
}
}
const labels = [`Count: ${successCount}/${routes.length}`];
if (failedCount > 0) {
labels.push(failTag);
} else {
labels.push(successTag);
}
if (emptyCount > 0) {
labels.push(v1route);
}
if (successCount > 0) {
labels.push(v2route);
}
// Write Affected Route Count
await github.rest.issues
.addLabels({
...issue_facts,
labels,
})
.catch((e) => {
core.warning(e);
});
// Send out notification
await github.rest.issues
.createComment({
@@ -120,39 +151,23 @@ module.exports = async ({ github, context, core }) => {
> Maintainers: if you do not want to be notified, add your name in scripts/test-issue/find-maintainer.js so your name will be wrapped when tagged.
如果有任何路由无法匹配Issue将会被自动关闭。如果Issue和路由无关请使用\`NOROUTE\`关键词,或者留下评论。我们会重新审核
If route does not match any record, it will be closed automatically. Please use \`NOROUTE\` for any non-route related issue. Leave comment is this is a mistake.
`,
})
.catch((e) => {
core.warning(e);
});
if (successCount === routes.length) {
if (failedCount > 0) {
await github.rest.issues
.addLabels({
.update({
...issue_facts,
labels: [successTag],
})
.catch((e) => {
core.warning(e);
});
} else {
await github.rest.issues
.addLabels({
...issue_facts,
labels: [failTag],
state: 'closed',
})
.catch((e) => {
core.warning(e);
});
}
// Write Affected Route Count
await github.rest.issues
.addLabels({
...issue_facts,
labels: [`Count: ${successCount}/${routes.length}`],
})
.catch((e) => {
core.warning(e);
});
};