@@ -31,45 +31,79 @@ jobs:
3131 - name : Check for duplicate filenames
3232 id : check
3333 run : |
34- echo "Checking for duplicate filenames between HTML_見送り and HTML_未着手 folders..."
34+ echo "Checking for duplicate filenames across HTML, HTML_見送り, and HTML_未着手 folders..."
3535
36- # Get basenames from both directories
37- dir1_files=$(find "WAIC-TEST/HTML_見送り" -name "*.md" -exec basename {} \; 2>/dev/null | sort)
38- dir2_files=$(find "WAIC-TEST/HTML_未着手" -name "*.md" -exec basename {} \; 2>/dev/null | sort)
36+ # Get basenames from all three directories
37+ html_files=$(find "WAIC-TEST/HTML" -name "*.md" ! -name "README.md" -exec basename {} \; 2>/dev/null | sort)
38+ miokuri_files=$(find "WAIC-TEST/HTML_見送り" -name "*.md" -exec basename {} \; 2>/dev/null | sort)
39+ michakushu_files=$(find "WAIC-TEST/HTML_未着手" -name "*.md" -exec basename {} \; 2>/dev/null | sort)
3940
40- # Find duplicates
41- duplicates=$(comm -12 <(echo "$dir1_files") <(echo "$dir2_files"))
41+ # Find duplicates and files to delete
42+ issue_body=""
43+ files_to_delete=""
44+ duplicates_found=false
4245
43- if [ -n "$duplicates" ]; then
44- echo "❌ Duplicate filenames found:"
45- echo "$duplicates"
46+ # Check HTML vs HTML_未着手 (delete from HTML_未着手)
47+ html_vs_michakushu=$(comm -12 <(echo "$html_files") <(echo "$michakushu_files"))
48+ if [ -n "$html_vs_michakushu" ]; then
49+ echo "❌ Duplicates found between HTML and HTML_未着手:"
50+ duplicates_found=true
51+ for file in $html_vs_michakushu; do
52+ echo " - $file"
53+ html_path=$(find WAIC-TEST/HTML -name "$file" -exec echo {} \;)
54+ michakushu_path=$(find WAIC-TEST/HTML_未着手 -name "$file" -exec echo {} \;)
55+ echo " 📁 HTML: $html_path"
56+ echo " 📁 HTML_未着手: $michakushu_path (削除対象)"
57+ issue_body="$issue_body- \`$file\`\n - 📁 HTML: \`$html_path\`\n - 📁 HTML_未着手: \`$michakushu_path\` (削除対象)\n\n"
58+ files_to_delete="$files_to_delete$michakushu_path\n"
59+ done
4660 echo ""
47- echo "Files exist in both HTML_見送り and HTML_未着手:"
48-
49- # Create detailed list for issue and files to delete
50- issue_body=""
51- files_to_delete=""
52- for file in $duplicates; do
61+ fi
62+
63+ # Check HTML vs HTML_見送り (delete from HTML_見送り)
64+ html_vs_miokuri=$(comm -12 <(echo "$html_files") <(echo "$miokuri_files"))
65+ if [ -n "$html_vs_miokuri" ]; then
66+ echo "❌ Duplicates found between HTML and HTML_見送り:"
67+ duplicates_found=true
68+ for file in $html_vs_miokuri; do
69+ echo " - $file"
70+ html_path=$(find WAIC-TEST/HTML -name "$file" -exec echo {} \;)
71+ miokuri_path=$(find WAIC-TEST/HTML_見送り -name "$file" -exec echo {} \;)
72+ echo " 📁 HTML: $html_path"
73+ echo " 📁 HTML_見送り: $miokuri_path (削除対象)"
74+ issue_body="$issue_body- \`$file\`\n - 📁 HTML: \`$html_path\`\n - 📁 HTML_見送り: \`$miokuri_path\` (削除対象)\n\n"
75+ files_to_delete="$files_to_delete$miokuri_path\n"
76+ done
77+ echo ""
78+ fi
79+
80+ # Check HTML_見送り vs HTML_未着手 (delete from HTML_未着手)
81+ miokuri_vs_michakushu=$(comm -12 <(echo "$miokuri_files") <(echo "$michakushu_files"))
82+ if [ -n "$miokuri_vs_michakushu" ]; then
83+ echo "❌ Duplicates found between HTML_見送り and HTML_未着手:"
84+ duplicates_found=true
85+ for file in $miokuri_vs_michakushu; do
5386 echo " - $file"
5487 miokuri_path=$(find WAIC-TEST/HTML_見送り -name "$file" -exec echo {} \;)
5588 michakushu_path=$(find WAIC-TEST/HTML_未着手 -name "$file" -exec echo {} \;)
56- echo " 📁 HTML_見送り/ $miokuri_path"
57- echo " 📁 HTML_未着手/ $michakushu_path"
58- issue_body="$issue_body- \`$file\`\n - 📁 \`$miokuri_path\`\n - 📁 \`$michakushu_path\`\n\n"
89+ echo " 📁 HTML_見送り: $miokuri_path"
90+ echo " 📁 HTML_未着手: $michakushu_path (削除対象) "
91+ issue_body="$issue_body- \`$file\`\n - 📁 HTML_見送り: \`$miokuri_path\`\n - 📁 HTML_未着手: \`$michakushu_path\` (削除対象) \n\n"
5992 files_to_delete="$files_to_delete$michakushu_path\n"
6093 done
61-
94+ echo ""
95+ fi
96+
97+ if [ "$duplicates_found" = true ]; then
6298 echo "duplicates_found=true" >> $GITHUB_OUTPUT
6399 echo "duplicate_list<<EOF" >> $GITHUB_OUTPUT
64100 echo -e "$issue_body" >> $GITHUB_OUTPUT
65101 echo "EOF" >> $GITHUB_OUTPUT
66102 echo "files_to_delete<<EOF" >> $GITHUB_OUTPUT
67103 echo -e "$files_to_delete" >> $GITHUB_OUTPUT
68104 echo "EOF" >> $GITHUB_OUTPUT
69-
70- # Don't fail, proceed to auto-fix
71105 else
72- echo "✅ No duplicate filenames found between the two directories."
106+ echo "✅ No duplicate filenames found across all directories."
73107 echo "duplicates_found=false" >> $GITHUB_OUTPUT
74108 fi
75109
83117 with :
84118 token : ${{ secrets.GITHUB_TOKEN }}
85119
86- - name : Delete duplicate files from HTML_未着手
120+ - name : Delete duplicate files
87121 run : |
88- echo "Deleting duplicate files from HTML_未着手 folder ..."
122+ echo "Deleting duplicate files..."
89123
90124 # Delete files listed in files_to_delete
91125 echo -e "${{ needs.check-duplicates.outputs.files_to_delete }}" | while read -r file; do
@@ -99,18 +133,18 @@ jobs:
99133 uses : peter-evans/create-pull-request@v7
100134 with :
101135 token : ${{ secrets.GITHUB_TOKEN }}
102- commit-message : " 🗑️ Remove duplicate files from HTML_未着手 folder [skip ci]"
103- title : " 🗑️ 重複ファイルの自動削除 (HTML_未着手) "
136+ commit-message : " 🗑️ Remove duplicate files across HTML folders [skip ci]"
137+ title : " 🗑️ 重複ファイルの自動削除"
104138 body : |
105139 ## 概要
106- HTML_見送り と HTML_未着手 フォルダ間で重複するファイルを検出し、HTML_未着手 から自動削除しました 。
140+ HTML、 HTML_見送り、 HTML_未着手 フォルダ間で重複するファイルを検出し、優先度の低いフォルダから自動削除しました 。
107141
108142 ## 削除されたファイル
109143 ${{ needs.check-duplicates.outputs.duplicate_list }}
110144
111- ## 削除理由
112- - ファイルが HTML_見送り フォルダに既に存在するため
113- - 重複を避けるために HTML_未着手 から削除
145+ ## 削除ルール
146+ - 優先度: HTML > HTML_見送り > HTML_未着手
147+ - 重複が見つかった場合、優先度の低い方から削除
114148
115149 ## 確認事項
116150 - [ ] 削除されたファイルの内容が HTML_見送り のファイルと同一であることを確認
0 commit comments