Skip to content

Commit 2ceb60c

Browse files
authored
Merge pull request #234 from justwriteclick/build
Updates for Oct 2023
2 parents 78f36d8 + fcbbe27 commit 2ceb60c

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

.github/workflows/greetings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ jobs:
99
- uses: actions/first-interaction@v1
1010
with:
1111
repo-token: ${{ secrets.GITHUB_TOKEN }}
12-
issue-message: 'Thanks for logging an issue. If you would like to fix it yourself, that''s fine. Assign yourself and send in a PR.'
12+
issue-message: 'Thanks for logging an issue for the docslikecode.com website. If you would like to fix it yourself, that''s fine. Assign yourself and send in a PR. You can also log issues with the book, _Docs Like Code_, and the author will see them here.'
1313
pr-message: 'Thanks for sending a pull request. You can message me on LinkedIn or Twitter if I don''t respond here quickly.'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
layout: post
3+
title: "Protecting a Branch so Only the Docs Team Merges and Publishes"
4+
excerpt: .
5+
last_modified_at: Sun Oct 1 11:05:31 CDT 2023
6+
categories: articles
7+
author: annegentle
8+
tags: [cicd, reviews, docs, settings, GitHub]
9+
image:
10+
path: /images/guarded-lightbulb-rob-sinclair.png
11+
caption: "[Lightbulb in a protective cage, Attribution: Rob Sinclair.)"
12+
comments: false
13+
share: true
14+
---
15+
16+
# Designate a review team for a directory or collection of files
17+
18+
With GitHub, you have the capability to designate a review team. This setup works well for a scenario where a `docs` directory should be completely controlled by the documentation team. With a [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) file configuration, the documentation team does not need to ask for other reviewers for small changes like a typo or grammar fix. When a team member's account name or team name is in the `CODEOWNERS` file, you can protect the branch or folder from merges from any account not found in the file.
19+
20+
A `CODEOWNERS` file can be stored in a directory, or in the `.github` folder, where many configuration files are stored by default. You can protect a branch or multiple branches based on a naming pattern match using [protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches).
21+
22+
A straightforward example involves protecting the `docs` folder in the `main` branch, where the `main` branch is the branch used to publish the documentation. In this example, the org name is `justwriteclick` and the username is `annegentle`. You would name the file `CODEOWNERS` and store it in a `docs` directory.
23+
24+
```
25+
@justwriteclick/annegentle
26+
```
27+
28+
You can also use an email address instead of an account name. See an example with lots of use cases in the GitHub documentation [Example of a CODEOWNER file](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file).
29+
30+
Then, make sure that the branch is protected using the repository's **Setting** > **Branches** > **Branch protection rules** > **Add protection rule** button. Enter `main` for the **Branch name pattern** and then select **Require a pull request before merging**. The settings expand so you can also choose **Require review from Code Owners**. Once you have the settings, click the **Create** button at the bottom of the page. More details are in the [GitHub Docs](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches).
31+
32+
<img src="../../images/branch-protection-rule.png" alt="GitHub Branch protection rules settings.">
33+
34+
To see an example of this setup, look at the Microsoft 365 community documentation repository at https://github.com/MicrosoftDocs/microsoft-365-community/. The `CODEOWNERS` file contains a team name, `@microsoftdocs/officedocs-admin`, and those team members can review and merge the list of documents in the `CODEOWNERS` file. The documents contain configuration information as well as the `CODEOWNERS` file itself.
35+
36+
```
37+
docfx.json @microsoftdocs/officedocs-admin
38+
.openpublishing.build.ps1 @microsoftdocs/officedocs-admin
39+
.openpublishing.publish.config.json @microsoftdocs/officedocs-admin
40+
CODEOWNERS @microsoftdocs/officedocs-admin
41+
.acrolinx-config.edn @microsoftdocs/officedocs-admin
42+
```
43+
44+
Think about ways you can protect your branches with a known group of reviewers. This workflow builds trust and safety while also ensuring you can move fast when needed in a larger team and repository setting.

images/branch-protection-rule.png

190 KB
Loading

0 commit comments

Comments
 (0)