mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 10:08:02 +08:00
66 lines
1.4 KiB
JavaScript
66 lines
1.4 KiB
JavaScript
/* eslint-disable */
|
|
|
|
module.exports = async ({ github, context, core }, baseUrl, routes, number) => {
|
|
if (routes[0] === 'NOROUTE') {
|
|
return;
|
|
}
|
|
|
|
const links = routes.map((e) => {
|
|
const l = e.startsWith('/') ? e : `/${e}`;
|
|
return `${baseUrl}${l}`;
|
|
});
|
|
|
|
let com = 'Successfully generated as following:\n\n';
|
|
|
|
for (const lks of links) {
|
|
core.info(`testing route: ${lks}`);
|
|
// Intended, one at a time
|
|
const res = await github.request(`GET ${lks}`).catch((err) => {
|
|
com += `
|
|
|
|
<details>
|
|
<summary><a href="${lks}">${lks}</a> - **Failed**</summary>
|
|
|
|
\`\`\`
|
|
${err}
|
|
\`\`\`
|
|
</details>
|
|
|
|
`;
|
|
});
|
|
if (res && res.data) {
|
|
const { data } = res;
|
|
com += `
|
|
<details>
|
|
<summary><a href="${lks}">${lks}</a> - Success</summary>
|
|
|
|
\`\`\`
|
|
${data.split('\n').slice(0, 30).join('\n')}
|
|
\`\`\`
|
|
</details>
|
|
|
|
`;
|
|
}
|
|
}
|
|
github.issues
|
|
.addLabels({
|
|
issue_number: number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: ['Auto: Route Test Complete'],
|
|
})
|
|
.catch((e) => {
|
|
core.warning(e);
|
|
});
|
|
github.issues
|
|
.createComment({
|
|
issue_number: number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: com,
|
|
})
|
|
.catch((e) => {
|
|
core.warning(e);
|
|
});
|
|
};
|