Skip to content

Commit ae2bd93

Browse files
committed
add update of existing PR and old branch cleanup to generate idehelper
1 parent 5ddca12 commit ae2bd93

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

.github/workflows/generate_idehelper.yml

+33-1
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,45 @@ jobs:
6060
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6161

6262

63-
- name: Create Pull Request
63+
- name: Check for existing PR
6464
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 == ''
6586
run: |
6687
gh pr create \
6788
--base dev \
6889
--head ${{ env.branch_name }} \
6990
--title "Auto-generated IDE helper update" \
7091
--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
71103
env:
72104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)