Auto-merge Bot PRs #359
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright Contributors to the KubeOpenCode project | |
| name: Auto-merge Bot PRs | |
| on: | |
| # Daily schedule to process any pending bot PRs | |
| schedule: | |
| - cron: '0 0 * * *' # Every day at midnight UTC | |
| # Manual trigger for batch processing | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| auto-merge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Auto-merge bot PRs | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| merge_pr() { | |
| local pr_number=$1 | |
| local pr_title=$2 | |
| echo "Processing PR #$pr_number: $pr_title" | |
| # Direct merge - squash commits and delete branch | |
| if gh pr merge "$pr_number" --squash --delete-branch; then | |
| echo "Successfully merged PR #$pr_number" | |
| else | |
| echo "Failed to merge PR #$pr_number" | |
| fi | |
| } | |
| # schedule or workflow_dispatch: batch process all open bot PRs | |
| echo "Batch processing all open bot PRs..." | |
| # Dependabot PRs: merge all with passing checks | |
| echo "Processing Dependabot PRs..." | |
| gh pr list --author "app/dependabot" --state open --json number,title,statusCheckRollup | jq -c '.[] | select([.statusCheckRollup[] | select(.conclusion != "SUCCESS" and .conclusion != "NEUTRAL" and .conclusion != "SKIPPED" and .conclusion != null and .name != "auto-merge")] | length == 0)' | while read -r pr; do | |
| number=$(echo "$pr" | jq -r '.number') | |
| title=$(echo "$pr" | jq -r '.title') | |
| merge_pr "$number" "$title" | |
| done | |
| # kubeopencode-dev PRs: merge all with passing checks | |
| echo "Processing kubeopencode-dev PRs..." | |
| gh pr list --author "app/kubeopencode-dev" --state open --json number,title,statusCheckRollup | jq -c '.[] | select([.statusCheckRollup[] | select(.conclusion != "SUCCESS" and .conclusion != "NEUTRAL" and .conclusion != "SKIPPED" and .conclusion != null and .name != "auto-merge")] | length == 0)' | while read -r pr; do | |
| number=$(echo "$pr" | jq -r '.number') | |
| title=$(echo "$pr" | jq -r '.title') | |
| merge_pr "$number" "$title" | |
| done | |
| echo "Batch processing complete" |