Skip to content
Latchkey

PR Auto-merge workflow (aws/bedrock-agentcore-starter-toolkit)

The PR Auto-merge workflow from aws/bedrock-agentcore-starter-toolkit, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: aws/bedrock-agentcore-starter-toolkit.github/workflows/pr-automerge.ymlLicense Apache-2.0View source

What it does

This is the PR Auto-merge workflow from the aws/bedrock-agentcore-starter-toolkit repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
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 and Format',
              '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');

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: PR Auto-merge
 
on:
  pull_request_review:
    types: [submitted]
 
permissions:
  contents: write
  pull-requests: write
 
jobs:
  auto-merge:
    timeout-minutes: 30
    name: Auto-merge Release PRs
    runs-on: latchkey-small
    # 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 and Format',
              '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');
 

What changed

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow