@@ -11,7 +11,7 @@ permissions:
1111
1212env :
1313 CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
14- API_BASE : https://sentintel-content-dev-fue4ashcg9fnfge9.canadacentral-01.azurewebsites.net/ # π replace with your App Service base URL
14+ API_BASE : https://sentintel-content-dev-fue4ashcg9fnfge9.canadacentral-01.azurewebsites.net
1515
1616jobs :
1717 pr-validate :
2626 raw=$(curl -s \
2727 -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
2828 "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://${CLIENT_ID}")
29- echo "π Token response: $raw"
3029 token=$(echo "$raw" | jq -r '.value')
31- echo "βοΈ Token length: ${#token}"
3230 echo "TOKEN=$token" >> $GITHUB_ENV
3331
3432 # 2. Checkout the PR head (untrusted code)
3937 ref : ${{ github.event.pull_request.head.ref }}
4038 fetch-depth : 0
4139
42- # 3. Send a simple GET request to verify connectivity
43- - name : π‘ Send GET request to protected endpoint
40+ # 3. Send a simple GET request to "/"
41+ - name : π‘ Send GET request to protected root endpoint
4442 run : |
4543 echo "π GET $API_BASE/"
4644 response=$(curl -s -H "Authorization: Bearer $TOKEN" "$API_BASE/")
@@ -51,46 +49,33 @@ jobs:
5149 - name : π Collect changed JSON files
5250 id : prepare_json_files
5351 run : |
54- echo "π Finding changed JSON files..."
5552 BASE="origin/${{ github.event.pull_request.base.ref }}"
5653 HEAD="${{ github.event.pull_request.head.sha }}"
57- echo "Base ref: $BASE"
58- echo "Head SHA: $HEAD"
59-
6054 mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$')
61- echo "π§Ύ Changed JSON files: ${files[*]:-<none>}"
62-
6355 json_array="["
6456 for file in "${files[@]}"; do
65- echo "π Processing $file"
66- if [ -f "$file" ] && jq -e . "$file" > /dev/null 2>&1; then
57+ if [ -f "$file" ] && jq -e . "$file" > /dev/null; then
6758 content=$(jq -c . < "$file")
6859 json_array+="{\"filename\":\"$file\",\"content\":$content},"
69- else
70- echo "β Skipping invalid or missing JSON: $file"
7160 fi
7261 done
7362 json_array="${json_array%,}]"
7463 echo "$json_array" > files_payload.json
75- echo "β
Payload written to files_payload.json"
7664 echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV
7765
78- # 5. Send POST request with JSON payload
79- - name : π Send POST request with JSON payload
66+ # 5. Send POST request with JSON payload to "/"
67+ - name : π Send POST request with JSON payload to root
8068 run : |
8169 echo "π POST $API_BASE/"
8270 response=$(curl -s -w "\n%{http_code}" -X POST "$API_BASE/" \
8371 -H "Authorization: Bearer $TOKEN" \
8472 -H "Content-Type: application/json" \
8573 --data-binary "@$JSON_PAYLOAD_PATH")
86-
8774 body=$(echo "$response" | head -n -1)
8875 status_code=$(echo "$response" | tail -n1)
89-
9076 echo "π HTTP status: $status_code"
9177 echo "π Response body:"
9278 echo "$body" | jq . || true
93-
9479 if [ "$status_code" -ne 200 ]; then
9580 echo "β POST failed (HTTP $status_code)"
9681 exit 1
0 commit comments