-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (47 loc) · 1.55 KB
/
codeowners-validator.yml
File metadata and controls
54 lines (47 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: 'Codeowners validation'
on:
push:
paths:
- 'CODEOWNERS'
- 'docs/CODEOWNERS'
- '.github/CODEOWNERS'
- '.github/workflows/codeowners-validator.yml'
branches:
- '**'
schedule:
- cron: '29 20 * * *' # sync-with-template: adjust
workflow_dispatch: { }
permissions:
id-token: write
concurrency:
group: codeowners-validation-${{github.ref}}
cancel-in-progress: true
jobs:
codeowners-validation:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Get repository owner type
id: owner-type
run: |
REPO_JSON=$(curl -s "${{github.api_url}}/repos/${{github.repository}}" -H "Authorization: token ${{github.token}}")
OWNER_TYPE=$(echo $REPO_JSON | jq -r '.owner.type')
OWNER_TYPE=$(echo "$OWNER_TYPE" | tr '[:upper:]' '[:lower:]')
echo "owner-type=$OWNER_TYPE" | tee -a $GITHUB_OUTPUT
- name: Get GitHub Token
id: get-token
uses: remal/github-repository-token-issuer@v1
with:
scopes: |
contents: read
${{steps.owner-type.outputs.owner-type == 'organization' && 'members:read' || ''}}
- name: CODEOWNERS validation
if: ${{steps.owner-type.outputs.owner-type != 'organization'}}
uses: mszostok/codeowners-validator@v0.7.4
with:
github_access_token: '${{steps.get-token.outputs.token}}'
checks: ${{steps.owner-type.outputs.owner-type == 'organization' && '' || 'duppatterns,files,syntax'}}