Skip to content

Commit d7fb698

Browse files
authored
fix: LeetCode 이동 안되는 문제 해결
1 parent 86185b8 commit d7fb698

1 file changed

Lines changed: 39 additions & 36 deletions

File tree

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,59 @@
11
name: Move LeetCode Solutions
22

33
on:
4-
workflow_dispatch: # 수동 실행 옵션 유지
54
push:
6-
paths:
7-
- '[0-9][0-9][0-9][0-9]-*/**' # LeetHub가 생성하는 폴더 패턴 (예: 0020-valid-parentheses)
5+
branches: [ main ]
6+
workflow_dispatch:
87

98
jobs:
10-
move-files:
9+
normalize:
1110
runs-on: ubuntu-latest
11+
1212
steps:
13-
- name: Checkout repository
13+
- name: Checkout
1414
uses: actions/checkout@v3
15-
with:
16-
fetch-depth: 2 # 최근 커밋 기록을 가져오기 위해 설정
1715

18-
- name: Move LeetCode solutions
16+
- name: Normalize LeetCode directories
1917
run: |
20-
# 디버깅을 위한 현재 디렉토리 내용 출력
21-
echo "Current directory contents:"
22-
ls -la
23-
24-
# LeetCode 폴더가 없다면 생성
18+
shopt -s nullglob
19+
2520
mkdir -p LeetCode
26-
27-
# 변경된 파일 목록 확인
28-
echo "Changed files in this push:"
29-
git diff --name-only HEAD^ HEAD
30-
31-
# LeetHub가 생성한 폴더들을 LeetCode 폴더로 이동
32-
found=0
33-
for d in [0-9][0-9][0-9][0-9]-*; do
34-
if [ -d "$d" ]; then
35-
echo "Moving directory: $d"
36-
mv "$d" "LeetCode/" && found=1
21+
22+
echo "=== Before ==="
23+
ls -la
24+
25+
for d in ./*; do
26+
if [[ -d "$d" && "$d" =~ ^\./[0-9]{4}- ]]; then
27+
folder=$(basename "$d")
28+
target="LeetCode/$folder"
29+
30+
echo "Processing: $folder"
31+
32+
# 이미 존재하면 merge (파일만 이동)
33+
if [ -d "$target" ]; then
34+
echo "Merging into existing: $target"
35+
mv "$d"/* "$target"/ 2>/dev/null || true
36+
rm -rf "$d"
37+
else
38+
echo "Moving to: $target"
39+
mv "$d" "$target"
40+
fi
3741
fi
3842
done
39-
40-
# 이동할 폴더를 찾지 못했을 경우에도 오류로 처리하지 않음
41-
if [ $found -eq 0 ]; then
42-
echo "No matching directories found to move"
43-
fi
4443
45-
- name: Commit & Push changes
44+
echo "=== After ==="
45+
ls -la
46+
ls -la LeetCode
47+
48+
- name: Commit & Push
4649
run: |
47-
# 변경사항이 있는지 확인
4850
if git status --porcelain | grep .; then
49-
git config --global user.name 'github-actions[bot]'
50-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
51-
git add -A
52-
git commit -m "chore: Move LeetCode solutions to LeetCode folder"
51+
git config --global user.name "github-actions[bot]"
52+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
git add .
55+
git commit -m "chore: normalize LeetCode directory structure"
5356
git push
5457
else
55-
echo "No changes to commit"
58+
echo "No changes"
5659
fi

0 commit comments

Comments
 (0)