Skip to content

Commit b2612df

Browse files
authored
Update codeowners workflow for legal (#48200)
1 parent 05040f5 commit b2612df

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

.github/workflows/codeowners-legal.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ name: Codeowners - Legal
66

77
on:
88
workflow_dispatch:
9+
pull_request:
10+
types:
11+
- edited
12+
- opened
13+
- ready_for_review
14+
- reopened
15+
- synchronize
16+
paths:
17+
- 'content/**'
918

1019
permissions:
1120
contents: read
@@ -19,40 +28,31 @@ jobs:
1928
github.event.pull_request.head.ref != 'repo-sync' }}
2029
runs-on: ubuntu-latest
2130
steps:
22-
- name: Get files changed
23-
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd
24-
id: filter
25-
with:
26-
# Base branch used to get changed files
27-
base: 'main'
28-
29-
# Enables setting an output in the format in `${FILTER_NAME}_files
30-
# with the names of the matching files formatted as JSON array
31-
list-files: json
32-
33-
# Returns list of changed files matching each filter
34-
filters: |
35-
rai:
36-
- 'content/**'
37-
3831
- name: Check out repo
3932
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
4033

34+
- name: Get changed files
35+
id: changed-files
36+
uses: tj-actions/changed-files@40526807ee1e208a1a8c1bbe6bd2d1b044ef6368 # v40.0.2
37+
with:
38+
files: 'content/**'
39+
output_renamed_files_as_deleted_and_added: true
40+
4141
- name: Set up Node and dependencies
42+
if: steps.changed-files.outputs.any_changed == 'true'
4243
uses: ./.github/actions/node-npm-setup
4344

4445
- name: Check content type
46+
if: steps.changed-files.outputs.any_changed == 'true'
4547
id: checkContentType
4648
run: npm run check-content-type
4749
env:
48-
FILE_PATHS_CONTENT_TYPES: ${{ steps.filter.outputs.rai_files }}
50+
# all_changed_files does not include deleted files
51+
CHANGED_FILE_PATHS: ${{ steps.changed-files.outputs.all_changed_files }}
4952
CONTENT_TYPE: 'rai'
50-
- name: Logging
51-
run: |
52-
echo ${{ steps.checkContentType.outputs.contentType }}
5353

5454
- name: Add Legal team as a reviewer
55-
if: ${{ steps.checkContentType.outputs.contentType == 'true' }}
55+
if: steps.checkContentType.outputs.containsContentType == 'true'
5656
env:
5757
# The GH CLI uses a slightly different env name for
5858
# the token than the GITHUB_TOKEN used by actions

src/workflows/check-content-type.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ import coreLib from '@actions/core'
44

55
import { checkContentType } from '#src/workflows/fm-utils.js'
66

7-
const { FILE_PATHS_CONTENT_TYPES, CONTENT_TYPE } = process.env
7+
const { CHANGED_FILE_PATHS, CONTENT_TYPE } = process.env
88

99
main()
1010

1111
async function main() {
12-
const filePaths = JSON.parse(FILE_PATHS_CONTENT_TYPES)
12+
// CHANGED_FILE_PATHS is a string of space-separated
13+
// file paths. For example:
14+
// 'content/path/foo.md content/path/bar.md'
15+
const filePaths = CHANGED_FILE_PATHS.split(' ')
1316
const containsRai = checkContentType(filePaths, CONTENT_TYPE)
14-
console.log('filePaths', filePaths)
15-
console.log('containsRai', containsRai)
1617
if (containsRai.length === 0) {
17-
coreLib.setOutput('contentType', false)
18+
coreLib.setOutput('containsContentType', false)
1819
} else {
19-
coreLib.setOutput('contentType', true)
20+
coreLib.setOutput('containsContentType', true)
2021
}
2122
}

0 commit comments

Comments
 (0)