Skip to content

add yaml to sync test #1

add yaml to sync test

add yaml to sync test #1

name: Sync to Second Repository
on:
push:
branches:
- main
jobs:
sync:
runs-on: ubuntu-latest
steps:
# 1. Repository 클론
- name: Checkout Source Repository
uses: actions/checkout@v3
with:
submodules: true # 서브모듈도 함께 체크아웃
# 2. 변경된 파일 탐지
- name: Detect Changed Files
id: changes
run: |
# Git diff로 변경된 파일의 경로만 추출
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
echo "changed_files=$CHANGED_FILES" >> $GITHUB_ENV
# 3. 변경된 파일 복사
- name: Copy Changed Files to Second Repository
run: |
for FILE in $CHANGED_FILES; do
# 두 번째 repository 디렉토리에 파일 복사
cp --parents "$FILE" sanghoon/
done
# 4. 두 번째 repository에 변경 사항 커밋 및 Push
- name: Commit and Push to Second Repository
run: |
cd sanghoon
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
# 변경 사항 커밋
git add .
git commit -m "Sync changes from first repository [skip ci]" || echo "No changes to commit"
# 두 번째 repository에 push
git push origin main