@@ -31,13 +31,29 @@ jobs:
3131
3232 - name : Get changed files
3333 id : changed-files
34- uses : tj-actions/changed-files@v45
35- with :
36- files : |
37- registry/**/spec.yaml
38- registry/**/spec.yml
39- json : true
40- json_raw_format : true
34+ run : |
35+ if [ "${{ github.event_name }}" = "pull_request" ]; then
36+ # For PRs, get changed files between base and head
37+ BASE_SHA="${{ github.event.pull_request.base.sha }}"
38+ HEAD_SHA="${{ github.event.pull_request.head.sha }}"
39+
40+ # Get changed spec files
41+ CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -E '^registry/.*/spec\.ya?ml$' || true)
42+ else
43+ # For workflow_dispatch, get files changed in the last commit or all files if no recent changes
44+ CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep -E '^registry/.*/spec\.ya?ml$' || true)
45+
46+ # If no files in last commit, we'll handle this in the matrix step
47+ fi
48+
49+ # Convert to JSON array
50+ if [ -z "$CHANGED_FILES" ]; then
51+ echo "all_changed_files=[]" >> $GITHUB_OUTPUT
52+ else
53+ # Convert newline-separated list to JSON array
54+ JSON_ARRAY=$(echo "$CHANGED_FILES" | jq -R -s -c 'split("\n") | map(select(length > 0))')
55+ echo "all_changed_files=$JSON_ARRAY" >> $GITHUB_OUTPUT
56+ fi
4157
4258 - name : Set matrix for changed specs
4359 id : set-matrix
88104 uses : actions/checkout@v5
89105 with :
90106 token : ${{ secrets.GITHUB_TOKEN }}
107+ ref : ${{ github.head_ref || github.ref }}
91108
92109 - name : Set up Go
93110 uses : actions/setup-go@v5
0 commit comments