mirror of
https://github.com/QYG2297248353/appstore-1panel.git
synced 2026-01-17 17:47:57 +08:00
102 lines
3.4 KiB
YAML
102 lines
3.4 KiB
YAML
name: Renovate Auto-merge (patch/minor only)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
delay_minutes:
|
|
description: 'Optional delay in minutes before processing PRs (default 5)'
|
|
required: false
|
|
default: '5'
|
|
schedule:
|
|
- cron: "*/10 * * * *"
|
|
pull_request:
|
|
types: [ready_for_review]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
checks: read
|
|
|
|
env:
|
|
REPO: ${{ github.repository }}
|
|
|
|
jobs:
|
|
automerge:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout (optional)
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Optional delay
|
|
run: |
|
|
delay_input="${{ github.event.inputs.delay_minutes }}"
|
|
delay="${delay_input:-5}"
|
|
echo "Delaying for ${delay} minute(s)..."
|
|
sleep $((delay * 60))
|
|
|
|
- name: Debug list all PRs
|
|
run: |
|
|
echo "All open PRs (number / title / author):"
|
|
gh pr list --repo "$REPO" --state open --json number,title,author \
|
|
--jq '.[] | {number,title,author:.author.login}' || true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Find Renovate PR numbers
|
|
id: find_prs
|
|
run: |
|
|
prs=$(gh pr list --repo "$REPO" --state open --json number,title,author \
|
|
--jq '.[] | select(.author.login | test("renovate"; "i")) | .number' ) || true
|
|
echo "Found PR numbers: $prs"
|
|
echo "prs=$prs" >> $GITHUB_OUTPUT
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Process Renovate PRs (patch/minor only)
|
|
if: steps.find_prs.outputs.prs != ''
|
|
run: |
|
|
owner_repo="$REPO"
|
|
owner=$(echo "$owner_repo" | cut -d'/' -f1)
|
|
repo=$(echo "$owner_repo" | cut -d'/' -f2)
|
|
|
|
prs="${{ steps.find_prs.outputs.prs }}"
|
|
for pr in $prs; do
|
|
echo "=== Processing PR #$pr ==="
|
|
|
|
body=$(gh pr view "$pr" --repo "$owner_repo" --json body --jq .body)
|
|
|
|
update_type=$(echo "$body" | awk -F'|' '/\|/ { gsub(/ /,"",$3); if ($3 ~ /(major|minor|patch)/) {print $3; exit} }')
|
|
update_type=${update_type:-unknown}
|
|
echo "PR #$pr 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 "$owner_repo" --json headRefOid --jq .headRefOid 2>/dev/null || true)
|
|
if [[ -z "$sha" ]]; then
|
|
sha=$(gh api repos/$owner/$repo/pulls/$pr --jq .head.sha)
|
|
fi
|
|
echo "PR #$pr head SHA: $sha"
|
|
|
|
combined_state=$(gh api repos/$owner/$repo/commits/$sha/status --jq .state)
|
|
echo "Combined status: $combined_state"
|
|
|
|
inprogress=$(gh api repos/$owner/$repo/commits/$sha/check-runs \
|
|
--jq '.check_runs[] | select(.status == "in_progress" or .conclusion == null) | .name' | wc -l || true)
|
|
echo "In-progress checks: $inprogress"
|
|
|
|
if [[ "$combined_state" == "success" && "$inprogress" -eq 0 ]]; then
|
|
echo "Merging PR #$pr ..."
|
|
gh pr merge "$pr" --repo "$owner_repo" --squash --delete-branch --confirm || {
|
|
echo "Merge failed for PR #$pr"
|
|
}
|
|
else
|
|
echo "Checks not green for PR #$pr, skipping."
|
|
fi
|
|
done
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|