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
mainthat 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:
[
{
"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:
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:
gh api orgs/YOUR-ORG/actions/permissions/workflow{"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:
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:
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:
gh workflow run agent-approves-pr.yml -R OWNER/REPO -f pr=1Once the run had finished, the pull request showed the workflow’s approval:
gh pr view 1 -R OWNER/REPO --json reviewDecision,mergeStateStatus,reviews{
"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:
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:
gh run list -R OWNER/REPO --workflow security-scan.yml --json headBranch,event,status,conclusion{
"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:
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:
{"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 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:
{
"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:
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:
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"{"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:
{ "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:
{
"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:
Invalid rule 'workflows': Invalid parameter workflows: Workflow error at index 0: Workflow source repository 'loadbank/agent-reach-lab' has actions sharing disabledThe 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:
gh api -X PUT repos/OWNER/REPO/actions/permissions/access -f access_level=organizationWith 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:
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): mergedThat 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.
gh api orgs/YOUR-ORG/actions/permissions/workflow
gh api repos/OWNER/REPO/actions/permissions/workflowThe 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.
gh api repos/OWNER/REPO/rules/branches/mainLook 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.
gh api repos/OWNER/REPO/branches/main/protectionOn my repository it returned “Branch not protected,” because all of its rules were rulesets.
grep -rnE '(statuses|checks): write|write-all' .github/workflowsOn my repository’s main it found nothing. At the commit that added the lab-only workflow, it found that workflow’s two permission lines:
89c524d593a890ce1e0c16f9b0296ede783b0f0b:.github/workflows/agent-posts-status.yml:14: statuses: write
89c524d593a890ce1e0c16f9b0296ede783b0f0b:.github/workflows/agent-posts-status.yml:15: checks: writeIt 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.
gh run list -R OWNER/REPO --workflow security-scan.yml --json headBranch,event,status,conclusionA conclusion of action_required is a run waiting for someone to approve it.