@@ -29,47 +29,32 @@ jobs:
2929 token=$(echo "$raw" | jq -r '.value')
3030 echo "TOKEN=$token" >> $GITHUB_ENV
3131
32- # 2. Checkout the PR head (untrusted code)
33- - name : π Checkout PR head
32+ # 2. Checkout the PR head at the exact commit
33+ - name : π Checkout PR head at exact commit
3434 uses : actions/checkout@v3
3535 with :
3636 repository : ${{ github.event.pull_request.head.repo.full_name }}
37- ref : ${{ github.event.pull_request.head.ref }}
37+ ref : ${{ github.event.pull_request.head.sha }}
3838 fetch-depth : 0
3939
40- # 3. Send a simple GET request to "/"
41- - name : π‘ Send GET request to protected root endpoint
42- run : |
43- echo "π GET $API_BASE/"
44- response=$(curl -s -H "Authorization: Bearer $TOKEN" "$API_BASE/")
45- echo "π GET response:"
46- echo "$response" | jq . || true
47-
48-
49-
50-
51- # 4. Collect & inspect changed JSON files (fixed)
40+ # 3. Collect & inspect changed JSON files (fixed)
5241 - name : π Collect & inspect changed JSON files
5342 id : prepare_json_files
5443 run : |
5544 echo "π Finding changed JSON files..."
5645 BASE_BRANCH=${{ github.event.pull_request.base.ref }}
5746 echo "Base branch: $BASE_BRANCH"
5847
59- # 1) Fetch the latest main so origin/main is up to date
6048 git fetch origin $BASE_BRANCH
6149 echo "β
Fetched origin/$BASE_BRANCH"
6250
63- # 2) Diff using three-dot syntax against HEAD
6451 all_changed=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
6552 echo "π All changed files in PR:"
6653 echo "$all_changed"
6754
68- # 3) Filter for .json
6955 mapfile -t files < <(echo "$all_changed" | grep '\.json$' || true)
7056 echo "π§Ύ JSON files to process (${#files[@]}): ${files[*]:-<none>}"
7157
72- # 4) Build the JSON array
7358 json_array="["
7459 for file in "${files[@]}"; do
7560 echo "π Checking $file"
@@ -81,15 +66,21 @@ jobs:
8166 fi
8267 done
8368 json_array="${json_array%,}]"
84-
85- # 5) Debug and save
8669 echo "β
Final JSON array:"
8770 echo "$json_array"
8871 echo "$json_array" > files_payload.json
8972 echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV
9073 echo "β
Payload size: $(wc -c < files_payload.json) bytes"
9174
9275
76+ # 3. Send a simple GET request to "/"
77+ - name : π‘ Send GET request to protected root endpoint
78+ run : |
79+ echo "π GET $API_BASE/"
80+ response=$(curl -s -H "Authorization: Bearer $TOKEN" "$API_BASE/")
81+ echo "π GET response:"
82+ echo "$response" | jq . || true
83+
9384
9485 # 5. Send POST request with JSON payload to "/"
9586 - name : π Send POST request with JSON payload to root
0 commit comments