Skip to content

Commit fa132bb

Browse files
authored
Merge pull request #36960 from github/repo-sync
Repo sync
2 parents 4b2256f + 5e58d68 commit fa132bb

23 files changed

Lines changed: 152 additions & 463 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Get changed files
2+
description: Get a list of changed files
3+
4+
inputs:
5+
files:
6+
description: 'Files or directories to check for changes'
7+
required: false
8+
default: '.'
9+
head:
10+
description: 'Head ref to check for changes against'
11+
required: false
12+
13+
outputs:
14+
all_changed_files:
15+
description: 'List of all changed files (unfiltered)'
16+
value: ${{ steps.get_changes.outputs.all_changed_files }}
17+
filtered_changed_files:
18+
description: 'List of changed files matching the filter'
19+
value: ${{ steps.get_changes.outputs.filtered_changed_files }}
20+
21+
runs:
22+
using: 'composite'
23+
steps:
24+
- name: Gather changed files
25+
id: get_changes
26+
env:
27+
INPUT_FILES: ${{ inputs.files }}
28+
PR: ${{ github.event.pull_request.number }}
29+
HEAD: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref || inputs.head || github.ref_name }}
30+
shell: bash
31+
run: ${{ github.action_path }}/get-changed-files.sh
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
# Required environment variables:
4+
# $INPUT_FILES: Pattern(s) to filter files by (e.g., "content/** data/**")
5+
# $FILTER: Derived from INPUT_FILES, defaults to "." if not provided
6+
# $PR: Pull request number (if running in PR context)
7+
# $HEAD: Current branch or SHA for git diff
8+
9+
# Default value for files parameter if not provided
10+
FILTER=${INPUT_FILES:-.}
11+
12+
# Print the filter
13+
echo "__ using filter: __"
14+
echo "$FILTER"
15+
16+
# Find the file diff in the pull request or merge group
17+
# If its a pull request, use the faster call to the GitHub API
18+
# For push, workflow_dispatch, and merge_group, use git diff
19+
if [ -n "$PR" ]
20+
then
21+
echo "__ running gh pr diff __"
22+
DIFF=`gh pr diff $PR --name-only`
23+
if [ -z "$DIFF" ]; then
24+
echo "__ gh pr diff failed, falling back to git diff __"
25+
HEAD=$(gh pr view $PR --json headRefName --jq .headRefName)
26+
fi
27+
fi
28+
29+
if [ -z "$DIFF" ]; then
30+
echo "__ using branch name $HEAD __"
31+
git fetch origin main --depth 1
32+
echo "__ running git diff __"
33+
DIFF=`git diff --name-only origin/main $HEAD`
34+
fi
35+
36+
# So we can inspect the output
37+
echo "__ DIFF found __"
38+
echo "$DIFF"
39+
40+
# Filter the DIFF to just the directories specified in the input files
41+
if [ "$FILTER" != "." ]; then
42+
echo "__ filtering DIFF to only include $FILTER __"
43+
FILTERED_DIFF=""
44+
IFS=$'\n'
45+
for file in $DIFF; do
46+
while IFS= read -r pattern || [ -n "$pattern" ]; do
47+
clean_pattern=${pattern%/}
48+
if [[ $file == $clean_pattern || $file == $clean_pattern/* ]]; then
49+
FILTERED_DIFF="$FILTERED_DIFF $file"
50+
break
51+
fi
52+
done <<< "$FILTER"
53+
done
54+
unset IFS
55+
DIFF=$FILTERED_DIFF
56+
echo "__ filtered DIFF __"
57+
echo "$DIFF"
58+
fi
59+
60+
# Format the output
61+
echo "__ formatting output __"
62+
FORMATTED_DIFF=$(echo $DIFF | tr '\n' ' ' | tr -s ' ')
63+
echo "$FORMATTED_DIFF"
64+
65+
# Set the output for GitHub Actions
66+
if [[ -n "$GITHUB_OUTPUT" ]]; then
67+
echo "all_changed_files=$DIFF" >> "$GITHUB_OUTPUT"
68+
echo "filtered_changed_files=$FORMATTED_DIFF" >> "$GITHUB_OUTPUT"
69+
else
70+
echo "all_changed_files=$DIFF"
71+
echo "filtered_changed_files=$FORMATTED_DIFF"
72+
fi

.github/workflows/codespace-review-check.yml

Lines changed: 0 additions & 129 deletions
This file was deleted.

.github/workflows/codespace-review-down.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)