diff --git a/.github/workflows/uml.yml b/.github/workflows/uml.yml index 57ee4d04..6807d431 100644 --- a/.github/workflows/uml.yml +++ b/.github/workflows/uml.yml @@ -58,9 +58,18 @@ jobs: - name: Create PR for changes if: steps.changes.outputs.changes_exist == 'true' run: | - git checkout -b update-uml-diagrams + BRANCH_NAME="update-uml-diagrams" + + # Delete the branch locally and remotely if it exists + git branch -D $BRANCH_NAME 2>/dev/null || true + git push origin --delete $BRANCH_NAME 2>/dev/null || true + + # Create and push the new branch + git checkout -b $BRANCH_NAME git commit -m "Update UML Diagrams" - git push -u origin update-uml-diagrams + git push -u origin $BRANCH_NAME + + # Create PR (will fail gracefully if PR already exists) gh pr create \ --base main \ --title "Update UML Diagrams" \ @@ -68,6 +77,6 @@ jobs: This PR was created automatically by the [UML workflow](https://github.com/pymc-labs/CausalPy/blob/main/.github/workflows/uml.yml). See the logs [here](https://github.com/pymc-labs/CausalPy/actions/workflows/uml.yml) for more details." \ --label "no releasenotes" \ - --reviewer drbenvincent + --reviewer drbenvincent || echo "PR may already exist" env: GH_TOKEN: ${{ github.token }}