From 16b43c7b02030a785aa756d6306349cab1d12c4b Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Mon, 29 Apr 2024 16:58:54 +0530 Subject: [PATCH] fix: pr check validation in workflow --- .github/workflows/auto-merge.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index e0f1946cb..621a28eb6 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -80,5 +80,12 @@ jobs: - name: Create PR to Target Branch if: env.HAS_CONFLICTS == 'true' run: | - PR_URL=$(gh pr create --base $TARGET_BRANCH --head $SOURCE_BRANCH --title "sync: merge conflicts need to be resolved" --body "") - echo "Pull Request created: $PR_URL" + # get all pull requests and check if there is already a PR + PR_EXISTS=$(gh pr list --base $TARGET_BRANCH --head $SOURCE_BRANCH --json number | jq '.[] | .number') + if [ -n "$PR_EXISTS" ]; then + echo "Pull Request already exists: $PR_EXISTS" + else + echo "Creating new pull request" + PR_URL=$(gh pr create --base $TARGET_BRANCH --head $SOURCE_BRANCH --title "sync: merge conflicts need to be resolved" --body "") + echo "Pull Request created: $PR_URL" + fi