Skip to content

Commit 59a1a34

Browse files
Merge branch 'trial-testing:main' into main
2 parents b832cd4 + 5e4ffa2 commit 59a1a34

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

.github/workflows/auth_try.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,44 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- name: 🔄 Checkout PR HEAD at exact commit
21+
- name: Checkout PR code
2222
uses: actions/checkout@v3
2323
with:
24-
repository: ${{ github.event.pull_request.head.repo.full_name }}
25-
ref: ${{ github.event.pull_request.head.sha }}
2624
fetch-depth: 0
25+
ref: ${{ github.event.pull_request.head.ref }}
26+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2727

28-
- name: 📁 Collect changed JSON files
28+
- name: Get changed JSON files and contents to send to API endpoint
29+
id: prepare_json_files
2930
run: |
30-
echo "🔍 Finding changed JSON files..."
31-
BASE=${{ github.event.pull_request.base.ref }}
32-
33-
git fetch origin $BASE
34-
echo "✅ Fetched origin/$BASE"
31+
echo "Collecting changed JSON files..."
32+
BASE="${{ github.event.pull_request.base.sha }}"
33+
HEAD="${{ github.event.pull_request.head.sha }}"
3534
36-
echo "🔁 Git diff from origin/$BASE to HEAD:"
37-
git diff --name-only origin/$BASE...HEAD
35+
mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$')
36+
echo "Changed JSON files: ${files[@]}"
3837
39-
mapfile -t files < <(git diff --name-only origin/$BASE...HEAD | grep '\.json$' || true)
40-
41-
echo "🧾 JSON files to process (${#files[@]}): ${files[*]:-<none>}"
38+
if [ ${#files[@]} -eq 0 ]; then
39+
echo "No JSON files changed in this PR."
40+
echo "JSON_PAYLOAD_PATH=empty" >> $GITHUB_ENV
41+
exit 0
42+
fi
4243
4344
json_array="["
4445
for file in "${files[@]}"; do
4546
if [ -f "$file" ]; then
46-
content=$(jq -c . < "$file")
47-
json_array+="{\"filename\":\"$file\",\"content\":$content},"
47+
if jq -e . "$file" > /dev/null 2>&1; then
48+
content=$(jq -c . < "$file")
49+
json_array+="{\"filename\": \"${file}\", \"content\": $content},"
50+
else
51+
echo "❌ Invalid JSON structure in file: $file"
52+
exit 1
53+
fi
4854
fi
4955
done
5056
json_array="${json_array%,}]"
5157
echo "$json_array" > files_payload.json
5258
echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV
53-
echo "✅ Final JSON array:"
54-
cat files_payload.json
5559
5660
5761

0 commit comments

Comments
 (0)