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,39 +1,60 @@
|
|||||||
name: Auto merge Renovate PRs
|
name: Auto merge Renovate PRs
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "*/10 * * * *"
|
||||||
|
workflow_dispatch:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
types: [ready_for_review]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
automerge:
|
automerge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.actor == 'renovate[bot]' || github.actor == 'mend-renovate[bot]'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Extract update type from PR body
|
- name: Checkout
|
||||||
id: check
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: List open PRs from Renovate
|
||||||
run: |
|
run: |
|
||||||
body="${{ github.event.pull_request.body }}"
|
prs=$(gh pr list \
|
||||||
echo "PR Body: $body"
|
--repo ${{ github.repository }} \
|
||||||
|
--state open \
|
||||||
|
--json number,title,body,author \
|
||||||
|
--jq '.[] | select(.author.login=="renovate[bot]" or .author.login=="mend-renovate[bot]") | .number')
|
||||||
|
|
||||||
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 "Found PRs: $prs"
|
||||||
echo "Detected update_type=$update_type"
|
echo "prs=$prs" >> $GITHUB_ENV
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
echo "update_type=$update_type" >> $GITHUB_OUTPUT
|
- 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"
|
||||||
|
|
||||||
- name: Wait for all checks
|
if [[ "$update_type" == "patch" || "$update_type" == "minor" ]]; then
|
||||||
uses: lewagon/wait-on-check-action@v1.3.4
|
echo "Waiting for checks on PR #$pr ..."
|
||||||
with:
|
gh pr checks $pr --repo ${{ github.repository }}
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
wait-interval: 15
|
|
||||||
running-workflow-name: "Auto merge Renovate PRs"
|
|
||||||
|
|
||||||
- name: Merge PR if patch/minor
|
# 检查状态是否全绿
|
||||||
if: steps.check.outputs.update_type == 'patch' || steps.check.outputs.update_type == 'minor'
|
state=$(gh pr checks $pr --repo ${{ github.repository }} --json status,state --jq '.[].status' | grep -v COMPLETED || true)
|
||||||
run: |
|
if [[ -z "$state" ]]; then
|
||||||
gh pr merge ${{ github.event.pull_request.number }} \
|
echo "Merging PR #$pr ..."
|
||||||
--merge \
|
gh pr merge $pr \
|
||||||
--delete-branch \
|
--merge \
|
||||||
--repo ${{ github.repository }}
|
--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:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
Reference in New Issue
Block a user