diff --git a/.github/workflows/update-javavalidator.yml b/.github/workflows/update-javavalidator.yml index 5b46eed..472df3d 100644 --- a/.github/workflows/update-javavalidator.yml +++ b/.github/workflows/update-javavalidator.yml @@ -50,14 +50,20 @@ jobs: - name: Create patch for Java validator version in action.yml run: | - branchName="update-java-validator-version-$LATEST_RELEASE" - git checkout -b "$branchName" + BRANCH_NAME="update-java-validator-version-$LATEST_RELEASE" + REMOTE_REPO="https://github.com/FirelyTeam/firely-terminal-pipeline.git" + if git ls-remote --heads "$REMOTE_REPO" "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then + echo "Branch '$BRANCH_NAME' already exists. Skipping creation of PR." + exit 0 + fi + + git checkout -b "$BRANCH_NAME" yq -i ".inputs.JAVA_VALIDATOR_VERSION.default = \"$NEW_VERSION\"" action.yml git config --local user.name "github-actions[bot]" git config --local user.email "github-actions[bot]@users.noreply.github.com" git add action.yml git commit -m "Update JAVA_VALIDATOR_VERSION to $LATEST_RELEASE" - git push -u origin "$branchName" - gh pr create --base main --head "$branchName" --title "Update JAVA_VALIDATOR_VERSION to $LATEST_RELEASE" --body "This PR updates the JAVA_VALIDATOR_VERSION to $LATEST_RELEASE." + git push -u origin "$BRANCH_NAME" + gh pr create --base main --head "$BRANCH_NAME" --title "Update JAVA_VALIDATOR_VERSION to $LATEST_RELEASE" --body "This PR updates the JAVA_VALIDATOR_VERSION to $LATEST_RELEASE." env: GH_TOKEN: ${{ github.token }}