@@ -60,13 +60,45 @@ jobs:
60
60
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61
61
62
62
63
- - name : Create Pull Request
63
+ - name : Check for existing PR
64
64
if : env.has_changes == 'true'
65
+ id : check_pr
66
+ run : |
67
+ PR_NUMBER=$(gh pr list --base dev --state open --search "Auto-generated IDE helper update" --json number --jq '.[0].number' || echo "")
68
+ if [[ -n "$PR_NUMBER" ]]; then
69
+ echo "Existing PR found: #$PR_NUMBER"
70
+ echo "pr_number=$PR_NUMBER" >> $GITHUB_ENV
71
+ else
72
+ echo "No existing PR found."
73
+ fi
74
+ env :
75
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
76
+
77
+ - name : Update existing PR (if found)
78
+ if : env.pr_number != ''
79
+ run : |
80
+ gh pr edit ${{ env.pr_number }} --head ${{ env.branch_name }}
81
+ env :
82
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
83
+
84
+ - name : Create Pull Request (if no existing PR)
85
+ if : env.has_changes == 'true' && env.pr_number == ''
65
86
run : |
66
87
gh pr create \
67
88
--base dev \
68
89
--head ${{ env.branch_name }} \
69
90
--title "Auto-generated IDE helper update" \
70
91
--body "This PR updates the IDE helper files automatically."
92
+ env :
93
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
94
+
95
+ - name : Clean up old branches
96
+ run : |
97
+ for branch in $(git branch -r | grep 'origin/maint/update-ide-helper-' | sed 's/origin\///'); do
98
+ if [[ "$branch" != "$branch_name" ]]; then
99
+ echo "Deleting old branch: $branch"
100
+ git push origin --delete "$branch"
101
+ fi
102
+ done
71
103
env :
72
104
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments