Skip to content

Commit a388bc7

Browse files
authored
Improve UML workflow branch and PR handling (#581)
The workflow now deletes any existing 'update-uml-diagrams' branch locally and remotely before creating a new one, ensuring a clean state. PR creation will fail gracefully if a PR already exists, preventing errors in repeated runs.
1 parent 2b29e48 commit a388bc7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.github/workflows/uml.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,25 @@ jobs:
5858
- name: Create PR for changes
5959
if: steps.changes.outputs.changes_exist == 'true'
6060
run: |
61-
git checkout -b update-uml-diagrams
61+
BRANCH_NAME="update-uml-diagrams"
62+
63+
# Delete the branch locally and remotely if it exists
64+
git branch -D $BRANCH_NAME 2>/dev/null || true
65+
git push origin --delete $BRANCH_NAME 2>/dev/null || true
66+
67+
# Create and push the new branch
68+
git checkout -b $BRANCH_NAME
6269
git commit -m "Update UML Diagrams"
63-
git push -u origin update-uml-diagrams
70+
git push -u origin $BRANCH_NAME
71+
72+
# Create PR (will fail gracefully if PR already exists)
6473
gh pr create \
6574
--base main \
6675
--title "Update UML Diagrams" \
6776
--body "This PR updates the UML diagrams
6877
This PR was created automatically by the [UML workflow](https://github.com/pymc-labs/CausalPy/blob/main/.github/workflows/uml.yml).
6978
See the logs [here](https://github.com/pymc-labs/CausalPy/actions/workflows/uml.yml) for more details." \
7079
--label "no releasenotes" \
71-
--reviewer drbenvincent
80+
--reviewer drbenvincent || echo "PR may already exist"
7281
env:
7382
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)