@@ -71,12 +71,34 @@ jobs:
7171 - name : Create Pull Request with changes
7272 if : steps.check.outputs.update == 'true'
7373 run : |
74+ BRANCH_NAME="update-trx-to-vsplaylist-${{ steps.get_version.outputs.latest }}"
75+
76+ # Check if PR already exists for this version
77+ EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --limit 1 --json number --jq '.[0].number // empty')
78+
79+ if [ -n "$EXISTING_PR" ]; then
80+ echo "PR #$EXISTING_PR already exists for version ${{ steps.get_version.outputs.latest }}"
81+ echo "No action needed - the update PR is already open"
82+ exit 0
83+ fi
84+
7485 git config user.name "github-actions[bot]"
7586 git config user.email "github-actions[bot]@users.noreply.github.com"
76- git checkout -b update-trx-to-vsplaylist-${{ steps.get_version.outputs.latest }}
87+
88+ # Clean up any existing branch (local or remote) to ensure a fresh start
89+ echo "Cleaning up any existing branch: $BRANCH_NAME"
90+ git branch -D "$BRANCH_NAME" 2>/dev/null && echo " Deleted local branch" || echo " No local branch to delete"
91+ if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then
92+ git push origin --delete "$BRANCH_NAME"
93+ echo " Deleted remote branch"
94+ else
95+ echo " No remote branch to delete"
96+ fi
97+
98+ git checkout -b "$BRANCH_NAME"
7799 git add action.yml
78100 git commit -m "chore: bump trx-to-vsplaylist to ${{ steps.get_version.outputs.latest }}"
79- gh pr create -B ${{ github.event.repository.default_branch }} -H update-trx-to-vsplaylist-${{ steps.get_version.outputs.latest }} \
101+ gh pr create -B ${{ github.event.repository.default_branch }} -H "$BRANCH_NAME" \
80102 --title "chore: bump trx-to-vsplaylist to ${{ steps.get_version.outputs.latest }}" \
81103 --body "Automated PR to update trx-to-vsplaylist tool version in action.yml to ${{ steps.get_version.outputs.latest }}"
82104 env :
0 commit comments