Skip to content

PR Auto-merge

PR Auto-merge #262

Workflow file for this run

name: PR Auto-merge
on:
pull_request_review:
types: [submitted]
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
name: Auto-merge Release PRs
runs-on: ubuntu-latest
# Only run when PR is approved and it's a release PR
if: |
github.event.review.state == 'approved' &&
github.event.pull_request.user.login == 'github-actions[bot]' &&
startsWith(github.event.pull_request.head.ref, 'release/') &&
github.event.pull_request.base.ref == 'main'
steps:
- name: Check CI status
id: ci-status
uses: actions/github-script@v7
with:
script: |
const { data: checkRuns } = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.payload.pull_request.head.sha
});
// Include ALL required checks
const requiredChecks = [
'Lint',
'Test Python 3.10',
'Test Python 3.11',
'Test Python 3.12',
'Test Python 3.13',
'Build Package'
];
const allPassed = requiredChecks.every(checkName => {
const check = checkRuns.check_runs.find(run => run.name === checkName);
return check && check.conclusion === 'success';
});
console.log(`All required checks passed: ${allPassed}`);
return allPassed;
- name: Auto-merge PR
if: steps.ci-status.outputs.result == 'true'
uses: actions/github-script@v7
with:
script: |
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
merge_method: 'squash',
commit_title: `Release v${context.payload.pull_request.head.ref.split('/')[1]}`,
commit_message: 'Auto-merged by release workflow'
});
console.log('✓ PR auto-merged successfully');