Update sync.yml #1
This file contains 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 repo | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
- name: Setup Git | |
run: | | |
git config --global user.name 'googoo9918' | |
git config --global user.email '[email protected]' | |
git remote add second https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OneDay-OneAlgorithm/JungDongGyu.git | |
- name: Fetch from second | |
run: git fetch second | |
- name: Create worktree | |
run: git worktree add ../worktree HEAD | |
- name: Remove .github directory in worktree | |
run: | | |
cd ../worktree | |
rm -rf .github | |
git add . | |
git commit --amend --no-edit | |
- name: Rebase onto second/main from worktree | |
run: | | |
cd ../worktree | |
git rebase second/main || git rebase --abort | |
- name: Merge second/main from worktree | |
if: failure() | |
run: | | |
cd ../worktree | |
git merge -X ours second/main | |
- name: Push to second from worktree | |
run: | | |
cd ../worktree | |
git push second HEAD:main --force-with-lease | |
- name: Clean up worktree | |
run: git worktree remove ../worktree |