Skip to content

Commit e6bd095

Browse files
Merge branch 'trial-testing:main' into main
2 parents 88f8465 + fc33dae commit e6bd095

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

.github/workflows/auth.yml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,47 @@ jobs:
2525
ref: ${{ github.event.pull_request.head.ref }}
2626
repository: ${{ github.event.pull_request.head.repo.full_name }}
2727

28+
29+
2830
- name: Get changed JSON files and contents to send to API endpoint
2931
id: prepare_json_files
3032
run: |
31-
echo "Collecting changed JSON files..."
32-
BASE="${{ github.event.pull_request.base.sha }}"
33-
HEAD="${{ github.event.pull_request.head.sha }}"
33+
echo "Collecting changed JSON files..."
34+
BASE="${{ github.event.pull_request.base.sha }}"
35+
HEAD="${{ github.event.pull_request.head.sha }}"
36+
37+
mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$')
38+
echo "Changed JSON files: ${files[@]}"
3439
35-
mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$')
36-
echo "Changed JSON files: ${files[@]}"
40+
filtered_files=()
41+
for file in "${files[@]}"; do
42+
if [[ "$file" =~ [Pp][Oo][Ll][Ll] ]]; then
43+
filtered_files+=("$file")
44+
fi
45+
done
3746
38-
if [ ${#files[@]} -eq 0 ]; then
39-
echo "No JSON files changed in this PR."
47+
if [ ${#filtered_files[@]} -eq 0 ]; then
48+
echo "No JSON files with 'poll' in the name changed in this PR."
4049
echo "JSON_PAYLOAD_PATH=empty" >> $GITHUB_ENV
4150
exit 0
42-
fi
51+
fi
4352
44-
json_array="["
45-
for file in "${files[@]}"; do
53+
json_array="["
54+
for file in "${filtered_files[@]}"; do
4655
if [ -f "$file" ]; then
47-
if jq -e . "$file" > /dev/null 2>&1; then
56+
if jq -e . "$file" > /dev/null 2>&1; then
4857
content=$(jq -c . < "$file")
4958
json_array+="{\"filename\": \"${file}\", \"content\": $content},"
50-
else
59+
else
5160
echo "❌ Invalid JSON structure in file: $file"
5261
exit 1
53-
fi
62+
fi
5463
fi
55-
done
56-
json_array="${json_array%,}]"
57-
echo "$json_array" > files_payload.json
58-
echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV
64+
done
65+
json_array="${json_array%,}]"
66+
echo "$json_array" > files_payload.json
67+
echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV
68+
5969
6070
- name: 🔐 Request OIDC token from GitHub
6171
id: fetch_token

0 commit comments

Comments
 (0)