Skip to content

Commit 1b6b85c

Browse files
authored
feat(ci): codeowners-enforcement use new sanity-check action (#16)
1 parent b2aba3b commit 1b6b85c

File tree

1 file changed

+5
-66
lines changed

1 file changed

+5
-66
lines changed

.github/workflows/codeowners-enforcement.yml

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,12 @@ jobs:
88
name: "Enforce"
99
runs-on: ubuntu-latest
1010
permissions:
11+
actions: read
1112
contents: read
1213
pull-requests: write
13-
env:
14-
COMMENT_FINGERPRINT: '<!-- chainlink-codeowners-enforcement -->'
1514
steps:
16-
- name: Checkout repo
17-
uses: actions/checkout@v5
18-
with:
19-
fetch-depth: 1
20-
persist-credentials: false
15+
- name: CODEOWNERS Sanity Check
16+
uses: smartcontractkit/.github/actions/codeowners-sanity-check@codeowners-sanity-check/v1
17+
env:
18+
GITHUB_TOKEN: ${{ github.token }}
2119

22-
- name: Check for CODEOWNERS file
23-
id: codeowners-file
24-
run: |
25-
# check at ./CODEOWNERS and .github/CODEOWNERS
26-
if [ ! -f CODEOWNERS ] && [ ! -f .github/CODEOWNERS ]; then
27-
echo "CODEOWNERS file not found"
28-
echo "found=false" | tee -a "$GITHUB_OUTPUT"
29-
else
30-
echo "found=true" | tee -a "$GITHUB_OUTPUT"
31-
fi
32-
33-
- name: Find PR Comment
34-
id: find-comment
35-
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
36-
with:
37-
issue-number: ${{ github.event.number }}
38-
body-includes: ${{ env.COMMENT_FINGERPRINT }}
39-
40-
- name: Upsert comment if no CODEOWNERS exists
41-
if: ${{ steps.codeowners-file.outputs.found == 'false' }}
42-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
43-
with:
44-
issue-number: ${{ github.event.number }}
45-
comment-id: ${{ steps.find-comment.outputs.comment-id }}
46-
edit-mode: 'replace'
47-
body: |
48-
### No CODEOWNERS file detected - @${{ github.actor }}
49-
50-
This repository doesn't contain a CODEOWNERS file. Please add one at one of the following paths:
51-
1. `CODEOWNERS` (root of repository)
52-
2. `.github/CODEOWNERS`
53-
54-
If this repository is owned/used by a single team the default entry for a CODEOWNERS would be:
55-
56-
```
57-
* @smartcontractkit/<your team>
58-
```
59-
60-
For more information see: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
61-
62-
${{ env.COMMENT_FINGERPRINT }}
63-
64-
- name: Update comment if CODEOWNERS was added
65-
if: ${{ steps.codeowners-file.outputs.found == 'true' && steps.find-comment.outputs.comment-id != '' }}
66-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
67-
with:
68-
issue-number: ${{ github.event.number }}
69-
comment-id: ${{ steps.find-comment.outputs.comment-id }}
70-
edit-mode: 'replace'
71-
body: |
72-
Thank you for adding a CODEOWNERS file - @${{ github.actor }}.
73-
74-
${{ env.COMMENT_FINGERPRINT }}
75-
76-
- name: Fail if no CODEOWNERS file is found
77-
if: ${{ steps.codeowners-file.outputs.found == 'false' }}
78-
run: |
79-
echo "::error::No CODEOWNERS file found."
80-
exit 1

0 commit comments

Comments
 (0)