1414 workflow_dispatch : { }
1515
1616permissions :
17- contents : read
17+ id-token : write
1818
1919concurrency :
2020 group : codeowners-validation-${{github.ref}}
2121 cancel-in-progress : true
2222
23- env :
24- VALIDATION_TOKEN : ${{secrets.CODEOWNERS_VALIDATOR_TOKEN && secrets.CODEOWNERS_VALIDATOR_TOKEN || github.token}}
25-
2623jobs :
27- rate-limits :
28- name : Check rate limits
29- runs-on : ubuntu-latest
30- timeout-minutes : 5
31- steps :
32- - name : Get rate limits
33- uses : remal-github-actions/get-rate-limits@v1
34- id : rate-limits
35- with :
36- githubToken : ${{env.VALIDATION_TOKEN || github.token}}
37- - name : Make decision
38- id : decision
39- run : |
40- echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}"
41- if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then
42- echo "Enough rate limits"
43- echo 'enough=true' >> $GITHUB_OUTPUT
44- else
45- echo "::warning::Not enough rate limits!"
46- if [ "${{github.event_name != 'schedule'}}" == "true" ]; then
47- echo "::warning::Executing anyway, as event is '${{github.event_name}}'"
48- echo 'enough=true' >> $GITHUB_OUTPUT
49- else
50- echo 'enough=false' >> $GITHUB_OUTPUT
51- fi
52- fi
53- outputs :
54- enough : ${{steps.decision.outputs.enough}}
55-
5624 codeowners-validation :
57- needs :
58- - rate-limits
59- if : ${{fromJSON(needs.rate-limits.outputs.enough) == true}}
6025 runs-on : ubuntu-latest
6126 timeout-minutes : 15
6227 steps :
@@ -68,20 +33,22 @@ jobs:
6833 - name : Get repository owner type
6934 id : owner-type
7035 run : |
71- REPO_JSON=$(curl -s "${{github.api_url}}/repos/${{github.repository}}" -H "Authorization: token ${{env.VALIDATION_TOKEN }}")
36+ REPO_JSON=$(curl -s "${{github.api_url}}/repos/${{github.repository}}" -H "Authorization: token ${{github.token }}")
7237 OWNER_TYPE=$(echo $REPO_JSON | jq -r '.owner.type')
7338 OWNER_TYPE=$(echo "$OWNER_TYPE" | tr '[:upper:]' '[:lower:]')
7439 echo "owner-type=$OWNER_TYPE" | tee -a $GITHUB_OUTPUT
7540
76- - name : Basic CODEOWNERS validation
77- if : ${{steps.owner-type.outputs.owner-type != 'organization'}}
78- 41+ - name : Get GitHub Token
42+ id : get-token
43+ uses : remal/github-repository-token-issuer@v1
7944 with :
80- github_access_token : ' ${{env.VALIDATION_TOKEN}}'
81- checks : ' syntax,duppatterns,files'
45+ scopes : |
46+ contents: read
47+ ${{steps.owner-type.outputs.owner-type == 'organization' && 'members:read' || ''}}
8248
83- - name : Full CODEOWNERS validation
84- if : ${{steps.owner-type.outputs.owner-type = = 'organization'}}
49+ - name : CODEOWNERS validation
50+ if : ${{steps.owner-type.outputs.owner-type ! = 'organization'}}
85518652 with :
87- github_access_token : ' ${{env.VALIDATION_TOKEN}}'
53+ github_access_token : ' ${{steps.get-token.outputs.token}}'
54+ checks : ${{steps.owner-type.outputs.owner-type == 'organization' && '' || 'duppatterns,files,syntax'}}
0 commit comments