From 047357aa426142d80664268ef1be7c3aab1e945b Mon Sep 17 00:00:00 2001 From: arezaii Date: Mon, 6 Jan 2025 13:19:01 -0700 Subject: [PATCH] Update monitor-homebrew.yml --- .github/workflows/monitor-homebrew.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monitor-homebrew.yml b/.github/workflows/monitor-homebrew.yml index e6bdbb2489ee..cd28569ae21f 100644 --- a/.github/workflows/monitor-homebrew.yml +++ b/.github/workflows/monitor-homebrew.yml @@ -3,7 +3,7 @@ name: Monitor Homebrew Formula on: workflow_dispatch env: - file_changed: ${{ false }} + file_changed: ${{ false }} jobs: check-and-update: @@ -29,6 +29,24 @@ jobs: else echo "file_changed=false" >> $GITHUB_ENV fi + + - name: Check if branch already exists + id: check-branch + run: | + BRANCH_NAME=update-chapel-homebrew-release-${{ env.HASH_SUBSTRING }} + if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then + echo "Branch $BRANCH_NAME already exists." + echo "branch_exists=true" >> $GITHUB_ENV + else + echo "Branch $BRANCH_NAME does not exist." + echo "branch_exists=false" >> $GITHUB_ENV + fi + + - name: Exit if branch exists + if: env.branch_exists == 'true' + run: | + echo "Branch already exists. Exiting." + exit 0 - name: Create a new branch if file has changed if: ${{ env.file_changed == 'true' }}