-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 1.8 KB
/
leetcode-move.yml
File metadata and controls
56 lines (48 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Move LeetCode Solutions
on:
workflow_dispatch: # 수동 실행 옵션 유지
push:
paths:
- '[0-9][0-9][0-9][0-9]-*/**' # LeetHub가 생성하는 폴더 패턴 (예: 0020-valid-parentheses)
jobs:
move-files:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # 최근 커밋 기록을 가져오기 위해 설정
- name: Move LeetCode solutions
run: |
# 디버깅을 위한 현재 디렉토리 내용 출력
echo "Current directory contents:"
ls -la
# LeetCode 폴더가 없다면 생성
mkdir -p LeetCode
# 변경된 파일 목록 확인
echo "Changed files in this push:"
git diff --name-only HEAD^ HEAD
# LeetHub가 생성한 폴더들을 LeetCode 폴더로 이동
found=0
for d in [0-9][0-9][0-9][0-9]-*; do
if [ -d "$d" ]; then
echo "Moving directory: $d"
mv "$d" "LeetCode/" && found=1
fi
done
# 이동할 폴더를 찾지 못했을 경우에도 오류로 처리하지 않음
if [ $found -eq 0 ]; then
echo "No matching directories found to move"
fi
- name: Commit & Push changes
run: |
# 변경사항이 있는지 확인
if git status --porcelain | grep .; then
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
git commit -m "chore: Move LeetCode solutions to LeetCode folder"
git push
else
echo "No changes to commit"
fi