diff --git a/.github/workflows/sync-pro.yml b/.github/workflows/sync-pro.yml index 4b152a17a0..022c4f11b4 100644 --- a/.github/workflows/sync-pro.yml +++ b/.github/workflows/sync-pro.yml @@ -10,6 +10,9 @@ jobs: if: ${{ github.repository == 'udecode/plate' && contains('refs/heads/main',github.ref)}} name: Sync Pro runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: - name: Checkout Repo uses: actions/checkout@v4 @@ -24,8 +27,6 @@ jobs: git config user.email '<>' PUSH_BRANCH=main PUSH_FORCE='' - git fetch $DOWNSTREAM main - git checkout $DOWNSTREAM/main -- yarn.lock # Checkout yarn.lock from downstream before merging git pull --no-rebase --no-edit $DOWNSTREAM main || { # Got merge conflicts, so fall back to upstream branch git merge --abort @@ -36,7 +37,7 @@ jobs: env: DOWNSTREAM: https://${{secrets.DOWNSTREAM_REPO_GITHUB_CREDENTIALS}}@github.com/plate-pro/plate-pro.git - # Open a PR if a branch called 'upstream' recieves commits on downstream + # Open a PR if a branch called 'upstream' receives commits on downstream upstream_pr: if: ${{ github.repository == 'plate-pro/plate-pro' && contains('refs/heads/upstream',github.ref)}} name: Upstream PR @@ -46,6 +47,12 @@ jobs: uses: actions/checkout@v4 - name: Create PR - run: gh pr create --title 'Sync upstream' --body '' + run: | + PR_EXIST=$(gh pr list | grep 'Sync upstream') + if [ -z "$PR_EXIST" ]; then + gh pr create --title 'Sync upstream' --body 'This PR synchronizes changes from the upstream branch.' + else + echo "Pull request already exists." + fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}