generated from remal/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (80 loc) · 2.73 KB
/
codeowners-validator.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: 'Codeowners validation'
on:
push:
paths:
- 'CODEOWNERS'
- 'docs/CODEOWNERS'
- '.github/CODEOWNERS'
- '.github/workflows/codeowners-validator.yml'
branches:
- '**'
schedule:
- cron: '14 5 * * *' # sync-with-template: adjust
workflow_dispatch: { }
permissions:
contents: read
env:
VALIDATION_TOKEN: ${{secrets.CODEOWNERS_VALIDATOR_TOKEN && secrets.CODEOWNERS_VALIDATOR_TOKEN || github.token}}
jobs:
rate-limits:
name: Check rate limits
runs-on: ubuntu-latest
timeout-minutes: 5
concurrency:
group: codeowners-validation
cancel-in-progress: true
steps:
- name: Get rate limits
uses: remal-github-actions/get-rate-limits@v1
id: rate-limits
with:
githubToken: ${{env.VALIDATION_TOKEN || github.token}}
- name: Make decision
id: decision
run: |
echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}"
if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then
echo "Enough rate limits"
echo 'enough=true' >> $GITHUB_OUTPUT
else
echo "::warning::Not enough rate limits!"
if [ "${{github.event_name != 'schedule'}}" == "true" ]; then
echo "::warning::Executing anyway, as event is '${{github.event_name}}'"
fi
echo 'enough=false' >> $GITHUB_OUTPUT
fi
outputs:
enough: ${{steps.decision.outputs.enough}}
codeowners-validation:
needs:
- rate-limits
if: ${{github.event_name != 'schedule' || fromJSON(needs.rate-limits.outputs.enough) == true}}
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: codeowners-validation
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
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 ${{env.VALIDATION_TOKEN}}")
OWNER_TYPE=$(echo $REPO_JSON | jq -r '.owner.type')
OWNER_TYPE=$(echo "$OWNER_TYPE" | tr '[:upper:]' '[:lower:]')
echo "Owner type: $OWNER_TYPE"
echo "::set-output name=owner-type::$OWNER_TYPE"
- name: Basic CODEOWNERS validation
if: ${{steps.owner-type.outputs.owner-type != 'organization'}}
uses: mszostok/codeowners-validator@v0.7.4
with:
github_access_token: '${{env.VALIDATION_TOKEN}}'
checks: 'syntax,duppatterns,files'
- name: Full CODEOWNERS validation
if: ${{steps.owner-type.outputs.owner-type == 'organization'}}
uses: mszostok/codeowners-validator@v0.7.4
with:
github_access_token: '${{env.VALIDATION_TOKEN}}'