update workflow #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync to Second Repository | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout the Source Repository | |
| - name: Checkout Source Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| # 2. Detect Changed Files | |
| - name: Detect Changed Files | |
| id: changes | |
| run: | | |
| if git rev-parse HEAD^ >/dev/null 2>&1; then | |
| CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) | |
| else | |
| CHANGED_FILES=$(git ls-files) | |
| fi | |
| echo "changed_files=$CHANGED_FILES" >> $GITHUB_ENV | |
| # 3. Copy Changed Files to Second Repository | |
| - name: Copy Changed Files to Second Repository | |
| run: | | |
| for FILE in $CHANGED_FILES; do | |
| cp --parents "$FILE" sanghoon/ | |
| done | |
| # 4. Commit and Push to Second Repository | |
| - 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" | |
| # PAT를 사용하여 HTTPS로 push | |
| git remote set-url origin https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/actionTestTempOrg/temp.git | |
| git push origin main |