← All notes

Note · GitHub

GitHub’s merge rules count accounts, not people

In a new GitHub organization, a workflow’s approval satisfied a required review, and a workflow’s commit status satisfied a required security scan that never ran. Requiring the scan workflow itself closed that gap.

The short version

  • A workflow’s approval counted as the one required review. I approved my own pull request by running a workflow.
  • A workflow posted a passing result for a required security scan without running it, and the pull request merged. Pinning the check to GitHub Actions didn’t stop it.
  • Two settings closed the gaps. Turning off “Allow GitHub Actions to create and approve pull requests” stopped the approval. An organization ruleset requiring the scan workflow itself stopped the faked scan.
  • Why it matters to me: when I answered security questionnaires, “every change is reviewed and scanned” was an easy yes. With agents opening pull requests, that answer depends on these settings.

These tests cover workflows that use the built-in GITHUB_TOKEN. Agents that use a GitHub App or a personal access token are a separate setup, which I haven’t tested yet.

What I tested

On December 2 and 3, 2026, I set up a new GitHub organization on the Team plan with one private repository. I ran everything with the GitHub CLI from a Linux virtual machine, signed in as the organization’s sole owner, and left the settings at their defaults apart from the changes below.

The repository started with:

  • A ruleset on main that requires one approving review, with nobody on the bypass list.
  • A stand-in security scan that runs on every pull request.
  • Two workflows that act like an agent with the built-in GITHUB_TOKEN. One opens a pull request, and the other approves one.

This is the ruleset as GitHub reports it, from the read-only check at the end of this note:

Active rules on main, trimmed
[
  {
    "type": "pull_request",
    "parameters": {
      "required_approving_review_count": 1,
      "dismiss_stale_reviews_on_push": false,
      "require_code_owner_review": false,
      "require_last_push_approval": false,
      "require_extra_approval_for_unattributed_changes": true
    },
    "ruleset_source_type": "Repository"
  }
]

GitHub added require_extra_approval_for_unattributed_changes as a default. As I read GitHub’s documentation, it applies to changes from Copilot, and it didn’t ask for a second approval in any of the tests below.

The scan only prints a line, which is enough to show whether it ran:

.github/workflows/security-scan.yml
name: security-scan
on: pull_request
permissions:
  contents: read
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo "Security scan ran for PR" \
            "#${{ github.event.pull_request.number }} from ${{ github.actor }}"

The setting

Under Settings → Actions → General, in the “Workflow permissions” section, there’s a checkbox labeled “Allow GitHub Actions to create and approve pull requests.” In my new organization it was off, both for the organization and in the repository. One call reads it:

Read the setting for an organization
gh api orgs/YOUR-ORG/actions/permissions/workflow
Output
{"default_workflow_permissions":"read","can_approve_pull_request_reviews":false}

The API field is named can_approve_pull_request_reviews, though it covers creating pull requests too. With it off, GitHub refused both of my agent workflows:

From the two workflow logs
pull request create failed: GraphQL: GitHub Actions is not permitted to create or approve pull requests (createPullRequest)
failed to create review: GraphQL: GitHub Actions is not permitted to approve pull requests. (addPullRequestReview)

The agent’s push to its own branch still went through. Only the pull request was refused. I turned the setting on at both levels for the tests below, then turned it back off.

A workflow’s approval counted as the required review

The approving workflow takes a pull request number and approves it. It’s the same gh pr review --approve call an AI review workflow would make:

.github/workflows/agent-approves-pr.yml
name: agent-approves-pr
on:
  workflow_dispatch:
    inputs:
      pr:
        description: Pull request number to approve
        required: true
permissions:
  pull-requests: write
jobs:
  approve:
    runs-on: ubuntu-latest
    steps:
      - name: Approve the pull request
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR: ${{ inputs.pr }}
        run: |
          gh pr review "$PR" -R "$GITHUB_REPOSITORY" --approve \
            --body "Approved by a workflow using GITHUB_TOKEN."

I opened pull request #1 under my own account, so I was its author, and its review state was REVIEW_REQUIRED. Then I ran the workflow against it:

Run the approving workflow
gh workflow run agent-approves-pr.yml -R OWNER/REPO -f pr=1

Once the run had finished, the pull request showed the workflow’s approval:

Read the pull request
gh pr view 1 -R OWNER/REPO --json reviewDecision,mergeStateStatus,reviews
Output, trimmed
{
  "mergeStateStatus": "CLEAN",
  "reviewDecision": "APPROVED",
  "reviews": [
    {
      "author": { "login": "github-actions" },
      "body": "Approved by a workflow using GITHUB_TOKEN.",
      "state": "APPROVED"
    }
  ]
}

gh pr merge 1 --merge then merged it. The ruleset asked for one approving review, and the workflow’s approval counted. Since I wrote the change and ran the workflow, I had in effect approved my own pull request. In this setup, anyone who can run that workflow could do the same.

The scan on the agent’s pull request waited, and the pull request merged

The other workflow commits a change on a new branch and opens a pull request:

.github/workflows/agent-opens-pr.yml
name: agent-opens-pr
on: workflow_dispatch
permissions:
  contents: write
  pull-requests: write
jobs:
  open:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Commit a change on a new branch and open a pull request
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          branch="agent/${{ github.run_id }}"
          git config user.name "github-actions[bot]"
          git config user.email \
            "41898282+github-actions[bot]@users.noreply.github.com"
          git switch -c "$branch"
          date -u > agent-change.txt
          git add agent-change.txt
          git commit -m "Agent change ${{ github.run_id }}"
          git push origin "$branch"
          gh pr create --head "$branch" \
            --title "Agent change ${{ github.run_id }}" \
            --body "Opened by a workflow using GITHUB_TOKEN."

GitHub’s documentation says a pull request opened with GITHUB_TOKEN creates its workflow runs in a state that waits for approval. That’s what happened when the workflow opened pull request #2. GitHub created a run of the scan but didn’t start it:

List runs of the scan
gh run list -R OWNER/REPO --workflow security-scan.yml --json headBranch,event,status,conclusion
Output, newest run only
{
  "conclusion": "action_required",
  "event": "pull_request",
  "headBranch": "agent/46971208512",
  "status": "completed"
}

On the pull request, the waiting scan appeared as a notice rather than as a check, and gh pr checks 2 reported no checks on the branch:

The merge box on pull request #2, showing "Review required", "1 workflow awaiting approval" with an "Approve workflows to run" button, and "Merging is blocked" Pull request #2. The scan waits until someone with write access clicks “Approve workflows to run.”

Only the missing review was blocking the merge. I had started the agent, and my approval was the only one the ruleset needed:

After my approval, then after the merge
{"reviewDecision":"APPROVED","mergeStateStatus":"UNSTABLE"}
{"state":"MERGED"}

GitHub’s API uses UNSTABLE for a pull request that can merge with a commit status that isn’t passing. When the pull request merged, GitHub ended the waiting run as a failure, and the scan job never started:

The security scan run after the merge: status Failure, the scan job never started, and an annotation reading "This workflow run required approval but was not approved before it expired" The scan run after the merge: “This workflow run required approval but was not approved before it expired.”

Requiring the scan wasn’t enough

Next I added a second rule to the ruleset, so the scan’s scan job has to pass before a pull request can merge:

The rule I added to the ruleset
{
  "type": "required_status_checks",
  "parameters": {
    "strict_required_status_checks_policy": false,
    "required_status_checks": [{ "context": "scan" }]
  }
}

On the agent’s next pull request, #3, GitHub held the scan again. I approved the pull request, and this time the merge was refused:

Merge attempt with the scan required
X Pull request loadbank/agent-reach-lab#3 is not mergeable: the base branch policy prohibits the merge.

Then I tested whether a workflow could mark the scan as passed without running it. I added a lab-only workflow with statuses: write and checks: write permissions that posts a passing scan result for a given commit. On the agent’s pull request #4, its commit status was enough:

The step in the lab-only workflow
run: |
  gh api "repos/$GITHUB_REPOSITORY/statuses/$SHA" \
    -f state=success -f context=scan \
    -f description="Posted by a workflow; the scan did not run"
What GitHub recorded, then the merge
{"context":"scan","creator":"github-actions[bot]","description":"Posted by a workflow; the scan did not run","state":"success"}
{"mergedAt":"2026-12-03T15:01:04Z","state":"MERGED"}

A ruleset can require a check to come from a specific app, so I pinned scan to the GitHub Actions app and ran the test again on pull request #5:

The required check, pinned to GitHub Actions
{ "context": "scan", "integration_id": 15368 }

It merged the same way. GitHub records anything a workflow posts with GITHUB_TOKEN as coming from GitHub Actions, so the pin tells GitHub Actions apart from other sources, but not one workflow from another.

To get the lab-only workflow onto main, I turned the ruleset off for one commit. In a real repository, a workflow like it would arrive through a reviewed merge, or it would be an agent’s own workflow given statuses: write.

What closed each gap

For the workflow’s approval, the setting itself was the control. With it off, the workflow couldn’t approve a pull request (the second error under “The setting”). With it on, which an agent needs before it can open pull requests with GITHUB_TOKEN, a workflow’s approval counts.

For the scan, an organization ruleset with “Require workflows to pass before merging” closed the gap. Rather than asking for a passing result named scan, it requires the security scan’s workflow file to run and pass:

The organization ruleset
{
  "name": "lab-require-scan-workflow",
  "target": "branch",
  "enforcement": "active",
  "conditions": {
    "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] },
    "repository_name": { "include": ["agent-reach-lab"], "exclude": [] }
  },
  "rules": [
    {
      "type": "workflows",
      "parameters": {
        "do_not_enforce_on_create": false,
        "workflows": [
          {
            "path": ".github/workflows/security-scan.yml",
            "repository_id": 1480987471,
            "ref": "refs/heads/main"
          }
        ]
      }
    }
  ]
}

GitHub refused to create it at first:

Creating the rule
Invalid rule 'workflows': Invalid parameter workflows: Workflow error at index 0: Workflow source repository 'loadbank/agent-reach-lab' has actions sharing disabled

The repository that holds the workflow has to share it. Under Settings → Actions → General → Access, I set it to the organization, and then the rule was created:

Let the organization’s repositories use this repository’s workflows
gh api -X PUT repos/OWNER/REPO/actions/permissions/access -f access_level=organization

With the rule in place, the agent’s pull request #7 was held for approval as before. This time, neither a posted commit status nor a posted check run got it merged:

Merge attempts on pull request #7
RESULT (approved, scan held): merge refused
RESULT (after a workflow posted a passing commit status): merge refused
RESULT (after a workflow posted a passing check run): merge refused
RESULT (after the held runs were approved): merged

That closed the gap, with two costs:

  • Someone with write access still has to approve the held run on every pull request a workflow opens with GITHUB_TOKEN. An agent’s pull requests wait for a person before they’re even checked.
  • None of these rules required a second person. I started the agent, approved its scan, approved its pull request and merged it, all as one user.

Check your own organization

Each of these commands only reads. Replace YOUR-ORG and OWNER/REPO with your own.

The setting, for the organization and for one repository
gh api orgs/YOUR-ORG/actions/permissions/workflow
gh api repos/OWNER/REPO/actions/permissions/workflow

The repository’s answer is the one that applies to its workflows. If can_approve_pull_request_reviews is true, workflows using GITHUB_TOKEN can open and approve pull requests there. default_workflow_permissions shows whether workflows that don’t set their own permissions start with read or write access.

The rules that apply to main, including organization rulesets
gh api repos/OWNER/REPO/rules/branches/main

Look for a workflows rule that names your security scan. A required_status_checks rule naming it stopped a merge while the scan waited, but a workflow’s posted status satisfied it.

Classic branch protection, which rulesets don’t show
gh api repos/OWNER/REPO/branches/main/protection

On my repository it returned “Branch not protected,” because all of its rules were rulesets.

Workflows that can post a status or check run, run in a clone of the repository
grep -rnE '(statuses|checks): write|write-all' .github/workflows

On my repository’s main it found nothing. At the commit that added the lab-only workflow, it found that workflow’s two permission lines:

Output at that commit, using git grep
89c524d593a890ce1e0c16f9b0296ede783b0f0b:.github/workflows/agent-posts-status.yml:14:  statuses: write
89c524d593a890ce1e0c16f9b0296ede783b0f0b:.github/workflows/agent-posts-status.yml:15:  checks: write

It only finds workflows that ask for these permissions themselves. A workflow without a permissions block gets the repository’s default, which the setting check above shows.

Runs of the scan and their state
gh run list -R OWNER/REPO --workflow security-scan.yml --json headBranch,event,status,conclusion

A conclusion of action_required is a run waiting for someone to approve it.

Updates

  • Added the follow-up tests. A workflow’s commit status satisfied the required scan check, and a required-workflow rule closed that gap. The first version said requiring the check was enough.

I last checked this on December 3, 2026. GitHub changes how these features behave from time to time. If you see something different, I’d like to hear about it at tom@ampeer.com.

Ampeer’s Agent Reach Assessment maps what a team’s AI agents can reach across GitHub, one cloud account and the agent tools they use. See the assessment