{"id":51620,"date":"2025-08-19T08:12:41","date_gmt":"2025-08-19T08:12:41","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=51620"},"modified":"2025-08-19T08:12:41","modified_gmt":"2025-08-19T08:12:41","slug":"what-is-github-codeowners","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-is-github-codeowners\/","title":{"rendered":"What is .github\/CODEOWNERS"},"content":{"rendered":"\n<p>The file <code>.github\/CODEOWNERS<\/code> is a <strong>special configuration file used by GitHub<\/strong> to define who is responsible for different parts of a repository\u2019s codebase.<\/p>\n\n\n\n<p>Here\u2019s a breakdown:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Location<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It lives inside the <code>.github<\/code> folder (or at the repo root).<\/li>\n\n\n\n<li>Common paths:\n<ul class=\"wp-block-list\">\n<li><code>.github\/CODEOWNERS<\/code><\/li>\n\n\n\n<li><code>docs\/CODEOWNERS<\/code><\/li>\n\n\n\n<li><code>CODEOWNERS<\/code> at the repo root<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Purpose<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It tells GitHub who the <strong>code owners<\/strong> are for specific files or directories.<\/li>\n\n\n\n<li>When someone opens a pull request that changes those files, the listed code owners are automatically requested for review.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Example<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Global owner (applies to everything)<\/span>\n*       @team-leads\n\n<span class=\"hljs-comment\"># Specific owners for backend<\/span>\n\/backend\/ @backend-team\n\n<span class=\"hljs-comment\"># Specific file owners<\/span>\n\/package.json @frontend-lead\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc How it Works<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GitHub matches file patterns (like <code>.gitignore<\/code> syntax).<\/li>\n\n\n\n<li>The last matching pattern in the file takes precedence.<\/li>\n\n\n\n<li>Code owners must have write access to the repository.<\/li>\n\n\n\n<li>They are automatically added as reviewers on PRs affecting their files.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Benefits<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clear responsibility for parts of the codebase.<\/li>\n\n\n\n<li>Enforced review process before merging.<\/li>\n\n\n\n<li>Helps large teams organize ownership and accountability.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Here\u2019s a <strong>sample <code>CODEOWNERS<\/code> file structure<\/strong> you can adapt to a multi-organization \/ multi-team project like Wizbrand. It covers global defaults, team-specific ownership, and even individual file rules.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc Sample <code>.github\/CODEOWNERS<\/code><\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># -----------------------------------<\/span>\n<span class=\"hljs-comment\"># Global default (everything not matched below)<\/span>\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n*               @org-leads\n\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n<span class=\"hljs-comment\"># Backend ownership<\/span>\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n\/backend\/        @backend-team\n\/backend\/api\/    @api-team\n\/backend\/db\/     @db-admins\n\n<span class=\"hljs-comment\"># Specific files<\/span>\n\/backend\/Dockerfile   @devops-team\n\/backend\/package.json @backend-lead\n\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n<span class=\"hljs-comment\"># Frontend ownership<\/span>\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n\/frontend\/      @frontend-team\n\/frontend\/ui\/   @ui-ux-team\n\/frontend\/src\/  @frontend-leads\n\n<span class=\"hljs-comment\"># Specific owners for critical config<\/span>\n\/frontend\/package.json   @frontend-lead\n\/frontend\/.eslintrc.js   @qa-team\n\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n<span class=\"hljs-comment\"># DevOps &amp; Infrastructure<\/span>\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n\/infra\/          @devops-team\n\/.github\/        @ci-cd-team\n\/k8s\/            @platform-team\n\n<span class=\"hljs-comment\"># Terraform &amp; Helm charts<\/span>\n\/infra\/terraform\/    @infra-team\n\/infra\/helm\/         @platform-team\n\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n<span class=\"hljs-comment\"># Documentation<\/span>\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n\/docs\/          @docs-team\nREADME.md       @docs-lead\n\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n<span class=\"hljs-comment\"># Security<\/span>\n<span class=\"hljs-comment\"># -----------------------------------<\/span>\n\/secrets\/       @security-team\n\/config\/        @security-team\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc Explanation<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>* @org-leads<\/code> \u2192 Default: If no other rule matches, <strong>organization leads<\/strong> own it.<\/li>\n\n\n\n<li><code>\/backend\/ @backend-team<\/code> \u2192 Whole backend directory goes to the backend team.<\/li>\n\n\n\n<li><code>backend\/Dockerfile @devops-team<\/code> \u2192 Specific file owned by DevOps.<\/li>\n\n\n\n<li><code>\/frontend\/ui\/ @ui-ux-team<\/code> \u2192 UI components handled by the design\/UX team.<\/li>\n\n\n\n<li><code>\/.github\/ @ci-cd-team<\/code> \u2192 All GitHub workflows and configs owned by CI\/CD team.<\/li>\n\n\n\n<li><code>\/docs\/ @docs-team<\/code> \u2192 Documentation owned by docs team, with <code>README.md<\/code> specifically assigned to docs lead.<\/li>\n\n\n\n<li><code>\/secrets\/ @security-team<\/code> \u2192 Anything sensitive is owned by the security team.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The file .github\/CODEOWNERS is a special configuration file used by GitHub to define who is responsible for different parts of a repository\u2019s codebase. Here\u2019s a breakdown: \ud83d\udccc Location \ud83d\udccc Purpose&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-51620","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/51620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=51620"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/51620\/revisions"}],"predecessor-version":[{"id":51621,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/51620\/revisions\/51621"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=51620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=51620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=51620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}