diff --git a/.github/workflows/codeowners.yml b/.github/workflows/codeowners.yml new file mode 100644 index 0000000..cb65a3e --- /dev/null +++ b/.github/workflows/codeowners.yml @@ -0,0 +1,38 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +# Reusable workflow to lint CODEOWNERS files in our *-infra repos + +name: Lint CODEOWNERS + +on: + workflow_call: + inputs: + exclude_dirs: + description: 'Directories to exclude from linting (space-separated, e.g. "projects misc modules")' + type: string + required: false + default: "" + +jobs: + lint-codeowners: + runs-on: ubuntu-latest + container: + image: us-west1-docker.pkg.dev/moz-fx-platform-artifacts/platform-shared-images/sre-citools:1.0 + options: --cpus 1 + steps: + - name: Clone Repository + uses: actions/checkout@v6 + with: + persist-credentials: false + + - name: Lint CODEOWNERS + run: | + exclude_args="" + for dir in ${INPUTS_EXCLUDE_DIRS}; do + exclude_args="$exclude_args --excludedirs $dir" + done + /usr/bin/lint-codeowners $GITHUB_WORKSPACE $exclude_args + env: + INPUTS_EXCLUDE_DIRS: ${{ inputs.exclude_dirs }} diff --git a/.github/workflows/docs/codeowners.md b/.github/workflows/docs/codeowners.md new file mode 100644 index 0000000..c75a7e9 --- /dev/null +++ b/.github/workflows/docs/codeowners.md @@ -0,0 +1,26 @@ +# CODEOWNERS Linting Reusable Workflow + +Validates CODEOWNERS files using the `lint-codeowners` tool found in [mozilla-it/sre-citools](https://github.com/mozilla-it/sre-citools). + +## Inputs + +| Name | Required | Type | Default | Description | +| -------------- | -------- | ------ | ------- | ------------------------------------------------------------------------ | +| `exclude_dirs` | false | string | `""` | Space-separated list of directories to exclude from linting (e.g. `"projects misc modules"`) | + +## Usage + +```yaml +name: Lint CODEOWNERS + +on: + pull_request: + paths: + - 'CODEOWNERS' + +jobs: + lint-codeowners: + uses: mozilla-it/deploy-actions/.github/workflows/codeowners.yml@main + with: + exclude_dirs: "projects misc modules" # optional: exclude specific directories +``` diff --git a/README.md b/README.md index cdebabd..6530597 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This repository contains GitHub Actions Composite Actions used for Deployment Au ## Workflows * [build-and-push](./.github/workflows/docs/build-and-push.md) +* [codeowners](./.github/workflows/docs/codeowners.md) * [diff-rendered-charts](./.github/workflows/docs/diff-rendered-charts.md) * [psa-checker](./.github/workflows/docs/psa-checker.md) * [validate-k8s-manifests](./.github/workflows/docs/validate-k8s-manifests.md)