File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Sync to Second Repository
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ sync :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ # 1. Repository 클론
14+ - name : Checkout Source Repository
15+ uses : actions/checkout@v3
16+ with :
17+ submodules : true # 서브모듈도 함께 체크아웃
18+
19+ # 2. 변경된 파일 탐지
20+ - name : Detect Changed Files
21+ id : changes
22+ run : |
23+ # Git diff로 변경된 파일의 경로만 추출
24+ CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
25+ echo "changed_files=$CHANGED_FILES" >> $GITHUB_ENV
26+
27+ # 3. 변경된 파일 복사
28+ - name : Copy Changed Files to Second Repository
29+ run : |
30+ for FILE in $CHANGED_FILES; do
31+ # 두 번째 repository 디렉토리에 파일 복사
32+ cp --parents "$FILE" sanghoon/
33+ done
34+
35+ # 4. 두 번째 repository에 변경 사항 커밋 및 Push
36+ - name : Commit and Push to Second Repository
37+ run : |
38+ cd sanghoon
39+ git config user.name "${{ github.actor }}"
40+ git config user.email "${{ github.actor }}@users.noreply.github.com"
41+
42+ # 변경 사항 커밋
43+ git add .
44+ git commit -m "Sync changes from first repository [skip ci]" || echo "No changes to commit"
45+
46+ # 두 번째 repository에 push
47+ git push origin main
You can’t perform that action at this time.
0 commit comments