mirror of
https://github.com/QYG2297248353/appstore-1panel.git
synced 2026-06-16 01:02:14 +08:00
61 lines
2.0 KiB
YAML
61 lines
2.0 KiB
YAML
name: Auto merge Renovate PRs
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "*/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
|
|
run: |
|
|
prs=$(gh pr list \
|
|
--repo ${{ github.repository }} \
|
|
--state open \
|
|
--json number,title,body,author \
|
|
--jq '.[] | select(.author.login=="renovate[bot]" or .author.login=="mend-renovate[bot]") | .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 "Checking 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 "PR #$pr update_type=$update_type"
|
|
|
|
if [[ "$update_type" == "patch" || "$update_type" == "minor" ]]; then
|
|
echo "Waiting for checks on PR #$pr ..."
|
|
gh pr checks $pr --repo ${{ github.repository }}
|
|
|
|
# 检查状态是否全绿
|
|
state=$(gh pr checks $pr --repo ${{ github.repository }} --json status,state --jq '.[].status' | grep -v COMPLETED || true)
|
|
if [[ -z "$state" ]]; then
|
|
echo "Merging PR #$pr ..."
|
|
gh pr merge $pr \
|
|
--merge \
|
|
--delete-branch \
|
|
--repo ${{ github.repository }}
|
|
else
|
|
echo "PR #$pr still has pending checks, skipping."
|
|
fi
|
|
else
|
|
echo "Skipping PR #$pr (not patch/minor)"
|
|
fi
|
|
done
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|