GitHub Code Security must be enabled in order to use code scanning on private repositories.
If you are on a GitHub Free or GitHub Pro plan, you can only use code scanning on repositories that are publicly available. To enable code scanning for private or internal repositories, you must upgrade to GitHub Team or GitHub Enterprise with GitHub Code Security and enable Code Security for the repository. For more information, see GitHub’s plans and About GitHub Advanced Security.