Skip to main content

require-codeql-pull-request-trigger

Rule catalog ID: R100

Targeted pattern scopeโ€‹

Workflows that run CodeQL analysis.

What this rule reportsโ€‹

This rule reports CodeQL workflows that do not listen for pull_request.

Why this rule existsโ€‹

Code scanning is most actionable when it runs against pull requests before merges happen. Requiring the PR trigger keeps CodeQL feedback in the developer loop.

โŒ Incorrectโ€‹

on:
push:
branches: [main]

โœ… Correctโ€‹

on:
push:
branches: [main]
pull_request:
branches: [main]

Additional examplesโ€‹

This rule only checks workflows that actually use CodeQL actions; it will not report on unrelated scheduled security workflows.

ESLint flat config exampleโ€‹

import githubActions from "eslint-plugin-github-actions-2";

export default [githubActions.configs.codeScanning];

When not to use itโ€‹

Disable this rule if your repository intentionally runs CodeQL only outside pull requests, for example in an external CI system.

Further readingโ€‹