File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Move LeetCode Solutions
2+
3+ on :
4+ workflow_dispatch : # 수동 실행 옵션 유지
5+ push :
6+ paths :
7+ - ' [0-9][0-9][0-9][0-9]-*/**' # LeetHub가 생성하는 폴더 패턴 (예: 0020-valid-parentheses)
8+
9+ jobs :
10+ move-files :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v3
15+ with :
16+ fetch-depth : 2 # 최근 커밋 기록을 가져오기 위해 설정
17+
18+ - name : Move LeetCode solutions
19+ run : |
20+ # 디버깅을 위한 현재 디렉토리 내용 출력
21+ echo "Current directory contents:"
22+ ls -la
23+
24+ # LeetCode 폴더가 없다면 생성
25+ 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
37+ fi
38+ done
39+
40+ # 이동할 폴더를 찾지 못했을 경우에도 오류로 처리하지 않음
41+ if [ $found -eq 0 ]; then
42+ echo "No matching directories found to move"
43+ fi
44+
45+ - name : Commit & Push changes
46+ run : |
47+ # 변경사항이 있는지 확인
48+ 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"
53+ git push
54+ else
55+ echo "No changes to commit"
56+ fi
You can’t perform that action at this time.
0 commit comments