Skip to content

Commit 933b140

Browse files
authored
Restore legal workflow (#54905)
1 parent e316b83 commit 933b140

4 files changed

Lines changed: 23 additions & 31 deletions

File tree

.github/actions/get-changed-files/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Get changed files
22
description: Get a list of changed files
33

44
inputs:
5-
file_filter:
5+
files:
66
description: 'Files or directories to check for changes, supports names, directories, trailing slashes, and single trailing wildcard'
77
required: false
88
default: '.'

.github/actions/get-changed-files/get-changed-files.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,25 @@ if [ "$FILTER" != "." ]; then
5858
echo "$DIFF"
5959
fi
6060

61-
# Format the output
6261
echo "__ formatting output __"
63-
FORMATTED_DIFF=$(echo $DIFF | tr '\n' ' ' | tr -s ' ')
64-
echo "$FORMATTED_DIFF"
62+
FORMATTED_DIFF=$(echo "$DIFF" | tr '\n' ' ' | tr -s ' ' | sed 's/^ *//' | sed 's/ *$//')
63+
echo "Formatted diff: '$FORMATTED_DIFF'"
6564

6665
# Set the output for GitHub Actions
67-
if [[ -n "$GITHUB_OUTPUT" ]]; then
68-
ALL_FORMATTED=$(echo "$DIFF" | tr '\n' ' ' | tr -s ' ')
69-
echo "all_changed_files=$ALL_FORMATTED" >> "$GITHUB_OUTPUT"
70-
echo "filtered_changed_files=$FORMATTED_DIFF" >> "$GITHUB_OUTPUT"
71-
else
72-
echo "all_changed_files=$DIFF"
73-
echo "filtered_changed_files=$FORMATTED_DIFF"
74-
fi
75-
76-
# If output file is specified, write the filtered changes to it
7766
if [[ -n "$INPUT_OUTPUT_FILE" ]]; then
78-
echo "$FORMATTED_DIFF" > "$INPUT_OUTPUT_FILE"
79-
echo "__ wrote changes to $INPUT_OUTPUT_FILE __"
67+
ALL_FORMATTED=$(echo "$DIFF" | tr '\n' ' ' | tr -s ' ' | sed 's/^ *//' | sed 's/ *$//')
68+
69+
# Only set outputs if there are actually changed files
70+
if [[ -z "$ALL_FORMATTED" ]]; then
71+
echo "No changed files detected, setting empty outputs"
72+
echo "all_changed_files=" >> "$INPUT_OUTPUT_FILE"
73+
echo "filtered_changed_files=" >> "$INPUT_OUTPUT_FILE"
74+
else
75+
echo "Setting non-empty outputs"
76+
echo "all_changed_files=$ALL_FORMATTED" >> "$INPUT_OUTPUT_FILE"
77+
echo "filtered_changed_files=$FORMATTED_DIFF" >> "$INPUT_OUTPUT_FILE"
78+
fi
79+
else
80+
echo "all_changed_files='$DIFF'"
81+
echo "filtered_changed_files='$FORMATTED_DIFF'"
8082
fi

.github/workflows/content-lint-markdown.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
steps:
2525
- name: Check out repo
2626
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
27-
with:
28-
fetch-depth: 10
2927

3028
- name: Set up Node and dependencies
3129
uses: ./.github/actions/node-npm-setup

.github/workflows/reviewers-legal.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,23 @@ jobs:
3333
steps:
3434
- name: Check out repo
3535
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
36-
with:
37-
# Picking this number is a "best guess". If we make it too large,
38-
# the checkout will take potentially unnecessarily long.
39-
# This reduces the chance that tj-actions/changed-files has to
40-
# fetch deeper history. But if it needs to, it will.
41-
fetch-depth: 10
4236

4337
- name: Get changed files
44-
id: changed-files
45-
uses: tj-actions/changed-files@40853de9f8ce2d6cfdc73c1b96f14e22ba44aec4 # v45.0.0
38+
id: changed_files
39+
uses: ./.github/actions/get-changed-files
4640
with:
4741
files: 'content/**'
48-
output_renamed_files_as_deleted_and_added: true
4942

5043
- name: Set up Node and dependencies
51-
if: steps.changed-files.outputs.any_changed == 'true'
44+
if: steps.changed_files.outputs.filtered_changed_files
5245
uses: ./.github/actions/node-npm-setup
5346

5447
- name: Check content type
55-
if: steps.changed-files.outputs.any_changed == 'true'
48+
if: steps.changed_files.outputs.filtered_changed_files
5649
id: checkContentType
5750
run: npm run check-content-type
5851
env:
59-
# all_changed_files does not include deleted files
60-
CHANGED_FILE_PATHS: ${{ steps.changed-files.outputs.all_changed_files }}
52+
CHANGED_FILE_PATHS: ${{ steps.changed_files.outputs.filtered_changed_files }}
6153
CONTENT_TYPE: 'rai'
6254

6355
- name: Check for reviewers-legal label, add if missing and request review

0 commit comments

Comments
 (0)