mirror of
https://github.com/QYG2297248353/appstore-1panel.git
synced 2026-06-16 01:02:14 +08:00
80 lines
2.8 KiB
YAML
80 lines
2.8 KiB
YAML
name: Auto merge Renovate PRs
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "*/10 * * * *" # 每 10 分钟跑一次
|
|
workflow_dispatch: # 支持手动触发
|
|
pull_request:
|
|
types: [ready_for_review]
|
|
|
|
jobs:
|
|
automerge:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
|
|
- name: List open PRs from Renovate
|
|
id: list
|
|
run: |
|
|
prs=$(gh pr list \
|
|
--repo ${{ github.repository }} \
|
|
--state open \
|
|
--json number,title,author \
|
|
--jq '.[] | select(.author.login | test("renovate";"i")) | .number')
|
|
echo "Found PRs: $prs"
|
|
echo "prs=$prs" >> $GITHUB_ENV
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Process each PR
|
|
if: env.prs != ''
|
|
run: |
|
|
for pr in $prs; do
|
|
echo "=== Processing PR #$pr ==="
|
|
|
|
body=$(gh pr view $pr --repo ${{ github.repository }} --json body --jq .body)
|
|
update_type=$(echo "$body" | grep -Eo '\|\s+[a-zA-Z0-9/_-]+\s+\|\s+(major|minor|patch)\s+\|' | head -n1 | awk -F'|' '{print $3}' | xargs)
|
|
echo "Detected update_type='$update_type'"
|
|
|
|
if [[ "$update_type" != "patch" && "$update_type" != "minor" ]]; then
|
|
echo "Skipping PR #$pr (not patch/minor)"
|
|
continue
|
|
fi
|
|
|
|
sha=$(gh pr view $pr --repo ${{ github.repository }} --json headRefOid --jq .headRefOid)
|
|
echo "PR #$pr head SHA: $sha"
|
|
|
|
# 最多等 30 分钟(30 次 * 60 秒)
|
|
for i in {1..30}; do
|
|
echo "🔎 Check attempt $i for PR #$pr ..."
|
|
|
|
# 获取 combined 状态
|
|
state=$(gh api repos/${{ github.repository }}/commits/$sha/status --jq .state)
|
|
echo "Combined status = $state"
|
|
|
|
# 获取详细 check-runs
|
|
echo "---- Check runs for $sha ----"
|
|
gh api repos/${{ github.repository }}/commits/$sha/check-runs \
|
|
--jq '.check_runs[] | {name: .name, status: .status, conclusion: .conclusion}' || true
|
|
echo "--------------------------------"
|
|
|
|
if [[ "$state" == "success" ]]; then
|
|
echo "✅ All checks passed for PR #$pr. Merging..."
|
|
gh pr merge $pr \
|
|
--squash \
|
|
--delete-branch \
|
|
--repo ${{ github.repository }}
|
|
break
|
|
elif [[ "$state" == "failure" ]]; then
|
|
echo "❌ Checks failed for PR #$pr. Skipping."
|
|
break
|
|
else
|
|
echo "⏳ Still pending checks for PR #$pr. Waiting 60s..."
|
|
sleep 60
|
|
fi
|
|
done
|
|
done
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|