优化一下GitHub action 输出

This commit is contained in:
zqlit committed 2026-05-20 14:42:30 +08:00
1 parent 1c3401ee79
commit 0ee5005b87
5 files changed
+3 -1567

No files matched your search

-53
View File
@@ -3,7 +3,6 @@ const path = require('path');
const matter = require('gray-matter');
const axios = require('axios');
const FRIEND_CIRCLE_PATH = path.join(__dirname, '../themes/Ying/static/json/friend_circle_data.json');
const LINK_SUMMARY_PATH = path.join(__dirname, '../failed_links_summary.txt');
const POSTS_DIR = path.join(__dirname, '../content/post');
const HUGO_CONFIG_PATH = path.join(__dirname, '../hugo.toml');
@@ -341,58 +340,6 @@ async function main() {
console.error("Error reading link summary:", e);
}
try {
if (fs.existsSync(FRIEND_CIRCLE_PATH)) {
const data = JSON.parse(fs.readFileSync(FRIEND_CIRCLE_PATH, 'utf8'));
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
const allPostsSorted = (data.posts || [])
.map(p => {
const dt = parseDateFlexible(p && p.date);
return Object.assign({}, p, { __date: dt });
})
.filter(p => p.__date instanceof Date && !Number.isNaN(p.__date.getTime()))
.sort((a, b) => b.__date.getTime() - a.__date.getTime());
const recentPosts = allPostsSorted.filter(post => post.__date > sevenDaysAgo);
const authorSet = new Set(recentPosts.map(p => p.author).filter(Boolean));
report += `### 👥 朋友圈近况 (近7天)\n`;
const circleMeta = getFileMetaString(FRIEND_CIRCLE_PATH);
if (circleMeta) report += `- 数据: ${circleMeta}\n`;
report += `- 更新: ${recentPosts.length} 条, 活跃作者: ${authorSet.size}\n`;
const toShow = recentPosts.length > 0 ? recentPosts : allPostsSorted;
if (toShow.length === 0) {
report += `无更新\n`;
report += `\n`;
} else {
if (recentPosts.length === 0) {
report += `- 近7天无更新,展示最近10条:\n`;
}
const limitedPosts = toShow.slice(0, 10);
limitedPosts.forEach(post => {
const dateStr = formatDateMDY(post.__date);
const author = post.author || '未知作者';
const link = post.link || post.url || '';
const blogUrl = post.blogUrl ? ` ${post.blogUrl}` : '';
if (link) {
report += `- [${author}] \`${link}\` (${dateStr})${blogUrl}\n`;
} else {
report += `- [${author}] (${dateStr})${blogUrl}\n`;
}
});
if (toShow.length > 10) {
report += `... 以及其他 ${toShow.length - 10} 篇\n`;
}
report += `\n`;
}
}
} catch (e) {
console.error("Error reading friend circle data:", e);
}
report += `### 🧩 环境\n`;
report += `- Node: ${process.version}\n`;
if (process.env.RUNNER_OS) report += `- Runner: ${process.env.RUNNER_OS}\n`;