-
Notifications
You must be signed in to change notification settings - Fork 66
131 lines (112 loc) · 4.37 KB
/
check_codeowners.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Check CODEOWNERS Entries
on:
pull_request:
branches:
- '*'
types:
- opened
- synchronize
- reopened
jobs:
check-additions:
name: Check Codeowners Additions
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Remove Review label
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ready-for-backend-review')
uses: actions-ecosystem/action-remove-labels@v1
with:
number: ${{ github.event.pull_request.number }}
labels: |
ready-for-backend-review
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.aws_access_key_id }}
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
aws-region: "us-gov-west-1"
- name: Get GitHub Bot Token
uses: marvinpinto/action-inject-ssm-secrets@v1.2.1
with:
ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN
env_variable_name: VA_VSP_BOT_GITHUB_TOKEN
- name: Check CODEOWNERS exists for new files
id: check_codeowners
run: |
chmod +x .github/scripts/check_codeowners.sh
.github/scripts/check_codeowners.sh
- name: Respond to PR if check CODEOWNERS exists for new files fails
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: 'Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: ${{ env.offending_file }}'
GITHUB_TOKEN: ${{ env.VA_VSP_BOT_GITHUB_TOKEN }}
- name: Add Failure label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ failure() }}
with:
number: ${{ github.event.pull_request.number }}
labels: |
codeowners-addition-failure
- name: Remove Failure label
uses: actions-ecosystem/action-remove-labels@v1
if: ${{ success() }}
with:
number: ${{ github.event.pull_request.number }}
labels: |
codeowners-addition-failure
check-deletions:
name: Check Codeowners Deletions
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Remove Review label
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ready-for-backend-review')
uses: actions-ecosystem/action-remove-labels@v1
with:
number: ${{ github.event.pull_request.number }}
labels: |
ready-for-backend-review
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.aws_access_key_id }}
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
aws-region: "us-gov-west-1"
- name: Get GitHub Bot Token
uses: marvinpinto/action-inject-ssm-secrets@v1.2.1
with:
ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN
env_variable_name: VA_VSP_BOT_GITHUB_TOKEN
- name: Check CODEOWNERS for removal when files deleted
id: check_deleted_files
run: |
chmod +x .github/scripts/check_deleted_files.sh
.github/scripts/check_deleted_files.sh
- name: Respond to PR if check CODEOWNERS exists for deleted files fails
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: 'Error: A file (or its parent directories) was deleted but its reference still exists in CODEOWNERS. Please update the .github/CODEOWNERS file and delete the entry for the Offending file: ${{ env.offending_file }}'
GITHUB_TOKEN: ${{ env.VA_VSP_BOT_GITHUB_TOKEN }}
- name: Add Failure label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ failure() }}
with:
number: ${{ github.event.pull_request.number }}
labels: |
codeowners-delete-failure
- name: Remove Failure label
uses: actions-ecosystem/action-remove-labels@v1
if: ${{ success() }}
with:
number: ${{ github.event.pull_request.number }}
labels: |
codeowners-delete-failure