DEV Community

Orta
Orta

Posted on

9 3

Let people own a subset of your repo

My Workflow

The Action: code-owner-self-merge

Using the CODEOWNERS format (a set of globs, then a set of GitHub usernames) you can define areas in a codebase which gives people the right to merge PRs which just affect their spaces.

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo orta / code-owner-self-merge

A GitHub Action for letting CODEOWNERS merge PRs via green PR reviews

A GitHub action that lets code-owners merge PRs via a comment.

This action uses the standardized structure of a CODEOWNERS file to handle the access controls.

A simple example

So, with this file at: .github/CODEOWNERS:

README.md @orta

If a PR contained only a change to the README.md - this action would say that "@orta has the ability to merge by commenting 'LGTM'".

Then, when/if this happens the GitHub Action will merge for you.

A real-world example

.github/CODEOWNERS:

# Collaborators for Japanese Translation of the Website
packages/playground-examples/copy/ja/** @sasurau4
 @quramy
 @naturalclar
 @Takepepe @orta

packages/tsconfig-reference/copy/ja/** @sasurau4
 @quramy
 @naturalclar
 @Takepepe @orta

packages/typescriptlang-org/src/copy/ja/** @sasurau4
 @quramy
 @naturalclar
 @Takepepe @orta

packages/documentation/copy/ja/** @sasurau4
 @quramy
 @naturalclar
 @Takepepe @orta

This allows any of @sasurau4, @Quramy, @Naturalclar, @Takepepe or @orta to merge PRs which affect their areas of the translation process in the TypeScript Website repo.

Setting It Up

You want a…


name: Codeowners merging
on:
  pull_request_target:
  issue_comment: { types: created }

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run Codeowners merge check
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      uses:  orta/code-owner-self-merge@v1

Additional Resources / Info

This is being used in the new TypeScript Website, to give translators access to merge PRs to their language: https://github.com/microsoft/TypeScript-Website/pull/899

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (1)

Collapse
 
waylonwalker profile image
Waylon Walker

Wow, that is a fascinating action.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more