From be728dc2dfc9f215205cc5e52fd2154005829715 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Thu, 20 Jun 2024 13:09:09 +0200 Subject: [PATCH] feat: update existing PR - uses same branch and title all the time --- .github/create-cli-pr.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/create-cli-pr.sh b/.github/create-cli-pr.sh index aea04baa9..71f8fd0b3 100755 --- a/.github/create-cli-pr.sh +++ b/.github/create-cli-pr.sh @@ -29,7 +29,7 @@ BODY=$(printf "## Changes since last integration of Language Server\n\n\`\`\`\n% pushd $CLI_DIR UPGRADE=$(go run scripts/upgrade-snyk-go-dependencies.go --name=snyk-ls) LS_VERSION=$(echo $UPGRADE | sed 's/.*Sha: \(.*\) URL.*/\1/') - BRANCH=feat/automatic-upgrade-of-ls-to-$LS_VERSION + BRANCH=feat/automatic-upgrade-of-ls git checkout -b $BRANCH git config --global user.email "team-ide@snyk.io" @@ -41,8 +41,15 @@ pushd $CLI_DIR git config --global user.signingkey ./signingkey.pub git commit -am "feat: automatic integration of language server $LS_VERSION" - git push --set-upstream origin $BRANCH - - gh pr create --repo github.com/snyk/cli --base main --head $BRANCH --title "feat(language-server): integrate LS ($LS_VERSION)" --body "$BODY" + git push -f --set-upstream origin $BRANCH + + TITLE="feat(language-server): integrate LS" + PR=$(gh pr list --search "$TITLE" 2>&1 | grep -e "$TITLE" | cut -f1) + if [[ ! $PR ]]; then + echo "Creating new PR" + gh pr create --repo github.com/snyk/cli --base main --head $BRANCH --title "$TITLE" --body "$BODY" + elif + gh pr edit $PR --repo github.com/snyk/cli --body "$BODY" + fi gh pr merge -m --auto popd