name: Auto Merge on: pull_request: types: [opened, reopened, ready_for_review] jobs: merge: runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - name: Checkout uses: actions/checkout@v6 - name: Auto Merge uses: actions/github-script@v7 env: PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} with: script: | const author = context.payload.pull_request.user.login; const association = context.payload.pull_request.author_association; // Trusted bot accounts (act as org members) const trustedBots = ['google-labs-jules[bot]']; const isTrustedBot = trustedBots.includes(author); // Check author association from webhook payload (no API call needed) const trusted = ['MEMBER', 'OWNER', 'COLLABORATOR']; if (!isTrustedBot && !trusted.includes(association)) { core.info(`${author} is ${association} — skipping auto-merge`); return; } await exec.exec('gh', [ 'pr', 'merge', process.env.PR_NUMBER, '--auto', ]); core.info(`Auto-merge enabled for #${process.env.PR_NUMBER}`);