-
Notifications
You must be signed in to change notification settings - Fork 96
72 lines (58 loc) · 2.54 KB
/
validate-codeowners.yml
File metadata and controls
72 lines (58 loc) · 2.54 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Validate CODEOWNERS
on:
workflow_dispatch:
pull_request_target:
paths:
- '.github/CODEOWNERS'
permissions:
contents: read
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-codeowners:
name: Validate CODEOWNERS members
if: github.repository == 'redhat-developer/rhdh-plugins'
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Get CODEOWNERS from PR
if: github.event_name == 'pull_request_target'
run: |
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-head
git checkout pr-head -- .github/CODEOWNERS
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2
with:
app-id: ${{ secrets.RHDH_GH_APP_ID }}
private-key: ${{ secrets.RHDH_GH_APP_PRIVATE_KEY }}
owner: redhat-developer
- name: Set up Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
- name: Validate CODEOWNERS entries against team membership
id: validate
continue-on-error: true
run: node scripts/ci/validate-codeowners.js
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Comment on PR if validation failed
if: steps.validate.outcome == 'failure' && github.event_name == 'pull_request_target' && steps.validate.outputs.missing_users != ''
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "## ⚠️ CODEOWNERS Validation Failed
The following users are listed in CODEOWNERS but are not members of the [\`rhdh-plugins-codeowners\`](https://github.com/orgs/redhat-developer/teams/rhdh-plugins-codeowners) team:
\`${{ steps.validate.outputs.missing_users }}\`
An org admin needs to [add the missing members to the team](https://github.com/orgs/redhat-developer/teams/rhdh-plugins-codeowners/members) before this PR can be merged."
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Fail workflow if validation failed
if: steps.validate.outcome == 'failure'
run: exit 1