-
Notifications
You must be signed in to change notification settings - Fork 1.1k
37 lines (37 loc) · 1.82 KB
/
check_for_new_files.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
name: Validate CODEOWNERS
on:
pull_request:
branches: [main]
jobs:
checkIfCodeownersUpdateNeeded:
permissions:
pull-requests: write # Used to add comment to PR
name: Check if CODEOWNERS needs to be updated
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 https://github.com/actions/checkout/commit/f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Get count of added files
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 https://github.com/actions/github-script/commit/d7906e4ad0b1822421a7e6a35d5ca353c962f410
id: set-added-files-count
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const { getAddedFiles } = require('./.github/workflows/scripts/check_for_new_files.js');
return getAddedFiles({github, context, core});
- name: Install npm package ignore
if: ${{ steps.set-added-files-count.outputs.result > 0 }}
run: yarn add ignore@5.2.4 -W # help verify CODEOWNERS
- name: Check file against CODEOWNERS
if: ${{ steps.set-added-files-count.outputs.result > 0 }}
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 https://github.com/actions/github-script/commit/d7906e4ad0b1822421a7e6a35d5ca353c962f410
env:
CURRENT_BRANCH: ${{ github.head_ref }}
CURRENT_REPO: ${{ github.repository }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const ignore = require('ignore');
const { validateCodeowners } = require('./.github/workflows/scripts/check_for_new_files.js');
validateCodeowners({github, context, fetch, ignore});