Add sync-pro.yml workflow #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 Pro | |
on: | |
push: | |
branches: [main, upstream] | |
jobs: | |
# Sync upstream commits to downstream | |
sync: | |
if: ${{ github.repository == 'udecode/plate' && contains('refs/heads/main',github.ref)}} | |
name: Sync Pro | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Perform Sync | |
run: | | |
# https://stackoverflow.com/a/69979203 | |
git config --unset-all http.https://github.com/.extraheader | |
git config user.name 'Sync Pro' | |
git config user.email '<>' | |
PUSH_BRANCH=main | |
PUSH_FORCE='' | |
git pull --no-rebase --no-edit $DOWNSTREAM main || { | |
# Got merge conflicts, so fall back to upstream branch | |
git merge --abort | |
PUSH_BRANCH=upstream | |
PUSH_FORCE=--force | |
} | |
git push $DOWNSTREAM HEAD:$PUSH_BRANCH $PUSH_FORCE | |
env: | |
DOWNSTREAM: https://${{secrets.DOWNSTREAM_REPO_GITHUB_CREDENTIALS}}@github.com/udecode/plate-pro.git | |
# Open a PR if a branch called 'upstream' recieves commits on downstream | |
upstream_pr: | |
if: ${{ github.repository == 'udecode/plate-pro' && contains('refs/heads/upstream',github.ref)}} | |
name: Upstream PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Create PR | |
run: gh pr create --title 'Sync upstream' --body '' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |