From 10ce3e215c2884d318165b30794b46dbb2b01be0 Mon Sep 17 00:00:00 2001 From: Zuoling Rong Date: Mon, 5 May 2025 21:37:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(bookmarks):=20=E5=88=86=E7=A6=BB=E4=B9=A6?= =?UTF-8?q?=E7=AD=BE=E5=A4=84=E7=90=86=E4=B8=8E=E6=B8=85=E7=90=86=E8=81=8C?= =?UTF-8?q?=E8=B4=A3=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=B8=85=E7=90=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将书签HTML文件的删除操作从 `bookmark-processor.js` 移至Actions工作流。 - `bookmark-processor.js` 现在仅负责解析书签并生成YAML配置。 --- .github/workflows/deploy.yml | 28 +++++++++++++++++++++------- src/bookmark-processor.js | 9 ++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b490b8f..1705c4e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -115,19 +115,33 @@ jobs: - name: Clean up processed bookmark files if: steps.check_bookmark_files.outputs.found == 'true' run: | - # 检查是否有html文件需要清理 - if [ "$(find bookmarks -type f -name "*.html" 2>/dev/null)" ]; then + # 先记录当前HTML文件列表 + HTML_FILES=$(find bookmarks -type f -name "*.html" 2>/dev/null) + if [ -n "$HTML_FILES" ]; then git config --local user.email "action@github.com" git config --local user.name "GitHub Action (Cleanup)" + echo "HTML files before cleanup:" + echo "$HTML_FILES" | tee html_files_before.txt + + # 计算文件数量 + FILE_COUNT=$(echo "$HTML_FILES" | wc -l) + echo "Found $FILE_COUNT HTML files to clean up." + + # 执行删除操作 echo "Cleaning up HTML files..." find bookmarks -type f -name "*.html" -delete - # 检查清理后是否有更改(比如删除了文件) - if ! git diff --quiet bookmarks/; then + + # 验证文件已被删除 + REMAINING=$(find bookmarks -type f -name "*.html" 2>/dev/null) + if [ -z "$REMAINING" ]; then + echo "All HTML files successfully deleted." + # 不管git diff结果如何,只要有文件被删除就提交 git add bookmarks/ - git commit -m "Clean up processed bookmark files" - # 不需要push + git commit -m "Clean up processed bookmark files ($FILE_COUNT files removed)" + echo "Changes committed." else - echo "No HTML files needed cleanup commit." + echo "WARNING: Some HTML files could not be deleted:" + echo "$REMAINING" fi else echo "No HTML files found to clean up." diff --git a/src/bookmark-processor.js b/src/bookmark-processor.js index 4d74f56..11a2748 100644 --- a/src/bookmark-processor.js +++ b/src/bookmark-processor.js @@ -404,13 +404,8 @@ async function main() { // 更新导航 updateNavigationWithBookmarks(); - // 处理完成后,删除原始HTML文件以防止重复处理 - try { - fs.unlinkSync(bookmarkFile); - console.log(`Deleted processed HTML file: ${bookmarkFile}`); - } catch (deleteError) { - console.warn(`Warning: Could not delete processed HTML file: ${deleteError.message}`); - } + // 不再删除原始HTML文件,留给GitHub Actions处理 + console.log(`Processing complete. HTML files will be cleaned up by GitHub Actions workflow.`); } catch (writeError) { console.error(`ERROR writing file:`, writeError); process.exit(1);