From bf4ded3e08bb6758cd24d2c54b47fbe40f7d6997 Mon Sep 17 00:00:00 2001 From: Jonah Stewart Date: Thu, 4 Sep 2025 15:04:14 -0400 Subject: [PATCH] add auto merge --- .github/workflows/auto_merge.yaml | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/auto_merge.yaml diff --git a/.github/workflows/auto_merge.yaml b/.github/workflows/auto_merge.yaml new file mode 100644 index 00000000..eac6e115 --- /dev/null +++ b/.github/workflows/auto_merge.yaml @@ -0,0 +1,63 @@ +name: Auto Approve and Merge +permissions: + checks: write + contents: write + pull-requests: write +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: [main] + workflow_dispatch: + inputs: + pr_number: + description: 'PR number to test auto-merge on' + required: false + type: string + +jobs: + auto-approve-merge: + runs-on: ubuntu-latest + if: | + github.event.pull_request.user.login == 'app/github-actions' && + contains(github.event.pull_request.title, 'Update SDK - Generate') + + steps: + - name: Check conditions + run: | + echo "🔍 Checking if should auto-merge..." + echo "PR Title: '${{ github.event.pull_request.title }}'" + echo "PR Author: '${{ github.event.pull_request.user.login }}'" + echo "Title condition: ${{ contains(github.event.pull_request.title, 'Update SDK - Generate') }}" + echo "Author condition: ${{ github.event.pull_request.user.login == 'app/github-actions' }}" + echo "Both conditions: ${{ github.event.pull_request.user.login == 'app/github-actions' && contains(github.event.pull_request.title, 'Update SDK - Generate') }}" + + if [[ "${{ github.event.pull_request.user.login }}" == "app/github-actions" && "${{ github.event.pull_request.title }}" == *"Update SDK - Generate"* ]]; then + echo "✅ Both conditions met - proceeding with auto-merge" + else + echo "❌ Conditions not met" + echo " - Author is github-actions: ${{ github.event.pull_request.user.login == 'app/github-actions' }}" + echo " - Title contains 'Update SDK - Generate': ${{ contains(github.event.pull_request.title, 'Update SDK - Generate') }}" + exit 0 # Don't fail, just skip + fi + + - name: Auto approve and merge + if: | + github.event.pull_request.user.login == 'app/github-actions' && + contains(github.event.pull_request.title, 'Update SDK - Generate') + run: | + echo "=== STARTING AUTO-MERGE PROCESS ===" + echo "PR Number: ${{ github.event.pull_request.number }}" + echo "Token available: ${{ secrets.AUTO_MERGE_TOKEN != '' }}" + + echo "Step 1: Approving PR..." + gh pr review ${{ github.event.pull_request.number }} --approve --body "Auto-approved by workflow" + echo "✅ Approval completed" + + echo "Step 2: Enabling auto-merge..." + gh pr merge ${{ github.event.pull_request.number }} --auto --merge --delete-branch + echo "✅ Auto-merge enabled" + + echo "Step 3: Final PR status..." + gh pr view ${{ github.event.pull_request.number }} --json state,mergeable,mergeStateStatus + env: + GH_TOKEN: ${{ secrets.AUTO_MERGE_TOKEN }} \ No newline at end of file