What the rule does#
A ruleset workflow is a workflow file in one source repository that an organization ruleset runs on pull requests in other repositories. "When you add this rule to a ruleset, in your organization settings, you specify the source repository and the workflow you want to enforce." Available rules for rulesets, Enterprise Cloud The REST API describes each entry by repository_id, path, and an optional ref or sha, "The commit SHA of the workflow file to use" (organization rulesets API).
That last field is the reason to use the rule. A repository's own pull_request workflow runs the workflow file from the pull request's merge commit (securely using pull_request_target), so a pull request can change the check that judges it. A ruleset workflow pinned to a SHA in another repository cannot be edited by the pull request it runs on.
Check availability before planning around it. The rule appears in the GitHub Enterprise Cloud version of the rulesets documentation and not in the Free, Pro and Team version, and the REST reference says Evaluate enforcement "is only available with GitHub Enterprise" (repository rulesets API).
How it differs from an ordinary workflow#
The rule changes several behaviors you may rely on in repository workflows. These come from GitHub's troubleshooting page for ruleset workflows and, for direct pushes, the rule's own documentation:
- Only
pull_request,pull_request_targetandmerge_grouptriggers are supported, and "Any filters you specify for the supported events are ignored - for example,branches,branches-ignore,paths,typesand so on." - "Ruleset workflows do not run on events triggered by the
GITHUB_TOKEN." - "If you create a rule while a pull request is open, the required workflow will not run automatically." Authors must push, update the branch, or close and reopen.
- The rule "will block direct pushes," so target only branches where every change arrives by pull request.
- Ruleset workflows "can't use the CodeQL actions, except
github/codeql-action/upload-sarif," and should not usecancel-in-progressconcurrency. - The source repository must allow access from the organization's repositories, and its visibility must be the same as or less restrictive than the targets'.
Ignored filters cut both ways. A central workflow cannot be skipped by a path filter, so it never leaves a check waiting the way a path-filtered required check does. It also runs on every pull request, so it must be cheap enough to run everywhere.
A fictional organization-wide policy check#
Suppose the acme organization wants every repository to reject new workflows that use pull_request_target without an exception. Doing this in each repository's own CI would mean forty copies, each editable by the pull requests it judges. Instead, the platform team keeps one workflow in acme/ci-policy:
name: workflow-policy
on:
pull_request:
merge_group:
permissions:
contents: read
jobs:
no-pull-request-target:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Reject pull_request_target triggers
run: |
if grep -rln 'pull_request_target' .github/workflows/ 2>/dev/null; then
echo "::error::pull_request_target needs an approved exception"
exit 1
fi
The ruleset applies it to every repository's default branch, pinned to the commit the platform team reviewed, and starts in Evaluate mode:
{
"name": "org: workflow policy",
"target": "branch",
"enforcement": "evaluate",
"conditions": {
"repository_name": { "include": ["~ALL"], "exclude": [] },
"ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] }
},
"rules": [
{
"type": "workflows",
"parameters": {
"workflows": [
{
"repository_id": 987654321,
"path": ".github/workflows/workflow-policy.yml",
"sha": "4f2c9e1d7b3a8c6e5d0f1a2b3c4d5e6f7a8b9c0d"
}
]
}
}
]
}
The repository ID and SHA are placeholders for your source repository and the reviewed commit. The body goes to POST /orgs/{org}/rulesets.
In Evaluate mode, the ruleset "will not be enforced," but you can "monitor which actions would or would not violate rules on the 'Rule Insights' page" (creating rulesets for repositories in your organization). The troubleshooting page adds that GitHub "does not log rule insights until a pull request is merged or a merge is attempted," so give Evaluate a few weeks of ordinary merges before reading it. Counting what the rule would have blocked is the subject of measuring a rule's false positives. When a ruleset workflow "runs in 'Evaluate' mode and passes, you can set the ruleset workflow to 'Active' mode and merge your pull request without triggering a new workflow run."
What the rule does not catch#
The workflow runs in the target repository's checkout, so it inspects whatever the pull request contains. A check that runs the repository's own scripts, such as npm test, still runs code the pull request can change. Central workflows are strongest for checks that read the change as data, like the one above, and weakest for checks that execute it.
Pinning to a SHA freezes the check. A fix in acme/ci-policy does nothing until someone updates the ruleset to the new commit, and an unpinned ref gives up the review boundary that made the rule worth using.
What it costs#
The rule can block repository creation, "since a workflow can't run against a repository that's being initialized," unless the ruleset is in Evaluate mode or someone with bypass permission creates the repository. It runs on every pull request in every targeted repository, which costs runner time everywhere at once, and a failure in the central workflow blocks every team. Give the source repository its own owners and review, because a change there is a change to every repository's merge policy.
The decision#
Use a ruleset workflow for a small number of checks that every repository must pass and that a pull request must not be able to weaken: policy checks over the diff, license or dependency rules, workflow hygiene. Pin it to a reviewed SHA, run it in Evaluate mode until Rule Insights shows what it would block, and then activate it. Keep build and test checks in each repository, protected by code owners on the workflow files.