Add Auto Merge #26
Workflow file for this run
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
| 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 }} |