-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (43 loc) · 1.3 KB
/
pr-auto-updater.yml
File metadata and controls
50 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: PR Auto Updater
on:
push:
branches:
- 'main'
- 'release/*'
tags-ignore:
- '*'
jobs:
pr-autoupdate:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.BOT_TOKEN }}
- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install gh -y
- name: Configure Git
run: |
git config --global user.email ${{ vars.BOT_EMAIL }}
git config --global user.name ${{ vars.BOT_USERNAME }}
- name: Update PR branches
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
GH_PROMPT_DISABLED: 1
run: |
prs=$(gh pr list --state open --base main --json number,headRefName -q '.[] | [.number, .headRefName] | @tsv')
while IFS=$'\t' read -r number branch; do
echo "Updating PR #$number (branch: $branch)"
git fetch origin "$branch"
git checkout "$branch"
if git merge origin/main --no-edit; then
git push origin HEAD:$branch
echo "✅ Updated $branch"
else
echo "❌ Merge conflict on $branch — skipped."
git merge --abort
fi
done <<< "$prs"