About configuring code scanning in multiple repositories
There are multiple ways to configure code scanning in multiple repositories at the same time.
The best method to use depends on the analysis needs of the repositories.
- The repositories are eligible for default setup for CodeQL and are owned by an organization.
- The group of repositories has similar configuration needs for CodeQL advanced setup.
In addition, GitHub Actions must be enabled for the organization.
Eligible repositories for CodeQL default setup
You can use the organization settings page for "Code security and analysis" to enable code scanning for all repositories in the organization that are eligible for CodeQL default setup.
If the code in a repository changes to include Go, JavaScript/TypeScript, Python, or Ruby, GitHub will automatically update the code scanning configuration to include the new language. If code scanning fails with the new configuration, GitHub will resume the previous configuration automatically so that the repository does not lose code scanning coverage. Compiled languages are not automatically included in the default setup configuration because they often require more advanced configuration, but you can manually add any CodeQL-supported compiled language other than Swift to your default setup configuration.
For more information about enabling security features across an organization, see "Securing your organization."
Eligibility criteria for organization-level enablement
A repository must meet all the following criteria to be eligible for default setup, otherwise you need to use advanced setup.
- Code scanning is not already enabled.
- GitHub Actions are enabled.
- Uses Go, JavaScript/TypeScript, Python, or Ruby.
- Publicly visible.
Note: If you disable CodeQL code scanning for all repositories this change is not reflected in the coverage information shown in security overview for the organization. The repositories will still appear to have code scanning enabled in the "Security Coverage" view.
For more information about default setup, see "Configuring code scanning for a repository." For information on editing security and analysis settings for an organization, see "Managing security and analysis settings for your organization."
Using a script to configure advanced setup
For repositories that are not eligible for default setup, you can use a bulk configuration script to configure advanced setup across multiple repositories.
- Identify a group of repositories that can be analyzed using the same code scanning configuration. For example, all repositories that build Java artifacts using the production environment.
- Create and test a GitHub Actions workflow to call the CodeQL action with the appropriate configuration. For more information, see "Configuring code scanning for a repository."
- Use one of the example scripts create a custom script to add the workflow to each repository in the group.
- PowerShell example:
jhutchings1/Create-ActionsPRsrepository - NodeJS example:
nickliffen/ghas-enablementrepository
- PowerShell example: