Skip to content

Update sync.yml

Update sync.yml #1

Workflow file for this run

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