File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-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+ fetch-depth : 0 # 모든 커밋 히스토리를 가져옴
19+
20+ # 2. 변경된 파일 탐지
21+ - name : Detect Changed Files
22+ id : changes
23+ run : |
24+ if git rev-parse HEAD^ >/dev/null 2>&1; then
25+ CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
26+ else
27+ CHANGED_FILES=$(git ls-files)
28+ fi
29+ echo "changed_files=$CHANGED_FILES" >> $GITHUB_ENV
30+
31+ # 3. 변경된 파일 복사
32+ - name : Copy Changed Files to Second Repository
33+ run : |
34+ for FILE in $CHANGED_FILES; do
35+ # 두 번째 repository 디렉토리에 파일 복사
36+ cp --parents "$FILE" sanghoon/
37+ done
38+
39+ # 4. 두 번째 repository에 변경 사항 커밋 및 Push
40+ - name : Commit and Push to Second Repository
41+ run : |
42+ cd sanghoon
43+ git config user.name "${{ github.actor }}"
44+ git config user.email "${{ github.actor }}@users.noreply.github.com"
45+
46+ # 변경 사항 커밋
47+ git add .
48+ git commit -m "Sync changes from first repository [skip ci]" || echo "No changes to commit"
49+
50+ # 두 번째 repository에 push
51+ git push origin main
You can’t perform that action at this time.
0 commit comments