/add-write-permissions-for-codeowners

A GitHub Action to add write permissions for CODEOWNERS.

Primary LanguageTypeScriptMIT LicenseMIT

add-write-permissions-for-codeowners

CI

This GitHub Action will add write permissions for the missing entries in the CODEOWNERS file.

Usage

Example

---
name: Add write permissions for CODEOWNERS

on:
  push:
    branches:
      - main
    paths:
      - 'CODEOWNERS'

permissions:
  contents: write

jobs:
  add-write-permissions-for-codeowners:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3

    - uses: Archetypically/add-write-permissions-for-codeowners@v1
      id: add-write-permissions-for-codeowners
      with:
        # Optional. The path to the CODEOWNERS file to format. Will auto-detect if not passed in.
        file-path: CODEOWNERS

        # Optional. Whether or not to actually perform the permissions update. Defaults to false.
        dry-run: false

        # Required. The GitHub token to use for the permissions update.
        # See "github-token" section below for more details.
        github-token: ${{ secrets.GITHUB_TOKEN }}

Parameters

Name Description Default
file-path The path to the CODEOWNERS file to format. Will auto-detect if not passed in. CODEOWNERS
dry-run Whether or not to actually perform the permissions update. false
github-token The GitHub token to use for the permissions update. -

github-token

If you are running this action in an org-scoped repository that will be operating on organization teams, you will likely need a personal access token (PAT) with the following scopes:

  • repo: in order to add teams/collaborators to the repository.
  • read:org: in order to list organization teams and their permissions on the repository.

If you instead are using a GitHub App's installation token, you will need to grant the following permissions to the token:

  • metadata: read: in order to list and collaborators and their permissions on the repository.
  • members: read: in order to read data on organization teams and their permissions on the repository.
  • administration: write: in order to add teams/collaborators to the repository.

Development

This repository intentionally does not use act for local development to reduce complexity.

Inputs are controlled via environment variables defined in development/.env.development.

Run the action using:

yarn action

which will operate on the file at development/CODEOWNERS.

Run the tests using:

yarn test

Credits

License

This project is licensed under the MIT License - see the LICENSE file for details.