mirror of
https://github.com/QYG2297248353/appstore-1panel.git
synced 2026-06-16 01:02:14 +08:00
Update auto_merge_renovate_prs.yml
This commit is contained in:
@@ -1,69 +1,60 @@
|
|||||||
name: Auto merge Renovate PRs
|
name: Renovate Automerge
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "*/10 * * * *"
|
- cron: "*/10 * * * *"
|
||||||
workflow_dispatch:
|
|
||||||
pull_request:
|
|
||||||
types: [ready_for_review]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
automerge:
|
automerge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Debug list all PRs
|
- name: Setup GitHub CLI
|
||||||
run: |
|
uses: cli/cli-action@v2
|
||||||
gh pr list \
|
with:
|
||||||
--repo ${{ github.repository }} \
|
version: latest
|
||||||
--state open \
|
|
||||||
--json number,title,author \
|
|
||||||
--jq '.[] | {number,title,author:.author.login}'
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: List open PRs from Renovate
|
- name: Find Renovate PRs
|
||||||
|
id: find_prs
|
||||||
run: |
|
run: |
|
||||||
prs=$(gh pr list \
|
prs=$(gh pr list \
|
||||||
--repo ${{ github.repository }} \
|
--repo ${{ github.repository }} \
|
||||||
--state open \
|
--state open \
|
||||||
--json number,title,body,author \
|
--json number,title,author \
|
||||||
--jq '.[] | select(.author.login=="renovate[bot]" or .author.login=="mend-renovate[bot]") | .number')
|
--jq '.[] | select(.author.login | test("renovate"; "i")) | .number')
|
||||||
|
|
||||||
echo "Found PRs: $prs"
|
echo "Found PRs: $prs"
|
||||||
echo "prs=$prs" >> $GITHUB_ENV
|
echo "prs=$prs" >> $GITHUB_ENV
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Process each PR
|
- name: Process PRs
|
||||||
if: env.prs != ''
|
if: env.prs != ''
|
||||||
run: |
|
run: |
|
||||||
for pr in $prs; do
|
for pr in $prs; do
|
||||||
echo "Checking PR #$pr ..."
|
echo "Checking PR #$pr ..."
|
||||||
body=$(gh pr view $pr --repo ${{ github.repository }} --json body --jq .body)
|
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)
|
# 提取更新类型 (patch/minor/major)
|
||||||
echo "PR #$pr update_type=$update_type"
|
update_type=$(echo "$body" | grep -oP '\|\s*(patch|minor|major)\s*\|' | head -n1 | tr -d '|[:space:]')
|
||||||
|
|
||||||
|
echo "PR #$pr update type: $update_type"
|
||||||
|
|
||||||
if [[ "$update_type" == "patch" || "$update_type" == "minor" ]]; then
|
if [[ "$update_type" == "patch" || "$update_type" == "minor" ]]; then
|
||||||
echo "Waiting for checks on PR #$pr ..."
|
echo "Merging PR #$pr ..."
|
||||||
gh pr checks $pr --repo ${{ github.repository }}
|
gh pr merge "$pr" \
|
||||||
|
--repo ${{ github.repository }} \
|
||||||
# 检查状态是否全绿
|
--squash \
|
||||||
state=$(gh pr checks $pr --repo ${{ github.repository }} --json status,state --jq '.[].status' | grep -v COMPLETED || true)
|
--auto
|
||||||
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
|
else
|
||||||
echo "Skipping PR #$pr (not patch/minor)"
|
echo "Skipping PR #$pr (type=$update_type)"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user