|
1 | | -name: pull_request_target |
| 1 | +# name: pull_request_target |
2 | 2 |
|
3 | | -on: |
4 | | - pull_request_target: |
5 | | - types: [opened, synchronize] |
| 3 | +# on: |
| 4 | +# pull_request_target: |
| 5 | +# types: [opened, synchronize] |
6 | 6 |
|
7 | | -jobs: |
8 | | - send-json-files: |
9 | | - runs-on: ubuntu-latest |
10 | | - steps: |
11 | | - - name: Checkout PR code |
12 | | - uses: actions/checkout@v3 |
13 | | - with: |
14 | | - fetch-depth: 0 |
15 | | - ref: ${{ github.event.pull_request.head.ref }} |
16 | | - repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 7 | +# jobs: |
| 8 | +# send-json-files: |
| 9 | +# runs-on: ubuntu-latest |
| 10 | +# steps: |
| 11 | +# - name: Checkout PR code |
| 12 | +# uses: actions/checkout@v3 |
| 13 | +# with: |
| 14 | +# fetch-depth: 0 |
| 15 | +# ref: ${{ github.event.pull_request.head.ref }} |
| 16 | +# repository: ${{ github.event.pull_request.head.repo.full_name }} |
17 | 17 |
|
18 | | - - name: Get changed JSON files and contents to send to API endpoint |
19 | | - id: prepare_json_files |
20 | | - run: | |
21 | | - echo "Collecting changed JSON files..." |
22 | | - BASE="${{ github.event.pull_request.base.sha }}" |
23 | | - HEAD="${{ github.event.pull_request.head.sha }}" |
| 18 | +# - name: Get changed JSON files and contents to send to API endpoint |
| 19 | +# id: prepare_json_files |
| 20 | +# run: | |
| 21 | +# echo "Collecting changed JSON files..." |
| 22 | +# BASE="${{ github.event.pull_request.base.sha }}" |
| 23 | +# HEAD="${{ github.event.pull_request.head.sha }}" |
24 | 24 |
|
25 | | - mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$') |
26 | | - echo "Changed JSON files: ${files[@]}" |
| 25 | +# mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$') |
| 26 | +# echo "Changed JSON files: ${files[@]}" |
27 | 27 |
|
28 | | - if [ ${#files[@]} -eq 0 ]; then |
29 | | - echo "No JSON files changed in this PR." |
30 | | - echo "JSON_PAYLOAD_PATH=empty" >> $GITHUB_ENV |
31 | | - exit 0 |
32 | | - fi |
| 28 | +# if [ ${#files[@]} -eq 0 ]; then |
| 29 | +# echo "No JSON files changed in this PR." |
| 30 | +# echo "JSON_PAYLOAD_PATH=empty" >> $GITHUB_ENV |
| 31 | +# exit 0 |
| 32 | +# fi |
33 | 33 |
|
34 | | - json_array="[" |
35 | | - for file in "${files[@]}"; do |
36 | | - if [ -f "$file" ]; then |
37 | | - if jq -e . "$file" > /dev/null 2>&1; then |
38 | | - content=$(jq -c . < "$file") |
39 | | - json_array+="{\"filename\": \"${file}\", \"content\": $content}," |
40 | | - else |
41 | | - echo "❌ Invalid JSON structure in file: $file" |
42 | | - exit 1 |
43 | | - fi |
44 | | - fi |
45 | | - done |
46 | | - json_array="${json_array%,}]" |
47 | | - echo "$json_array" > files_payload.json |
48 | | - echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV |
| 34 | +# json_array="[" |
| 35 | +# for file in "${files[@]}"; do |
| 36 | +# if [ -f "$file" ]; then |
| 37 | +# if jq -e . "$file" > /dev/null 2>&1; then |
| 38 | +# content=$(jq -c . < "$file") |
| 39 | +# json_array+="{\"filename\": \"${file}\", \"content\": $content}," |
| 40 | +# else |
| 41 | +# echo "❌ Invalid JSON structure in file: $file" |
| 42 | +# exit 1 |
| 43 | +# fi |
| 44 | +# fi |
| 45 | +# done |
| 46 | +# json_array="${json_array%,}]" |
| 47 | +# echo "$json_array" > files_payload.json |
| 48 | +# echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV |
49 | 49 |
|
50 | | - - name: Send JSON files to API and check response |
51 | | - if: env.JSON_PAYLOAD_PATH != 'empty' |
52 | | - env: |
53 | | - API_URL: https://valid1-e2akhdekg6a7a2ch.canadacentral-01.azurewebsites.net/ |
54 | | - run: | |
55 | | - echo "Sending JSON payload to API" |
56 | | - response=$(curl -s -X POST "$API_URL" \ |
57 | | - -H "Content-Type: application/json" \ |
58 | | - --data-binary "@$JSON_PAYLOAD_PATH") |
59 | | - status=$(jq -r '.status' <<< "$response") |
60 | | - message=$(jq -r '.message' <<< "$response") |
61 | | - if [ "$status" != "passed" ]; then |
62 | | - echo "❌ Test Fail : $message" |
63 | | - exit 1 |
64 | | - fi |
65 | | - echo "✅ $message" |
| 50 | +# - name: Send JSON files to API and check response |
| 51 | +# if: env.JSON_PAYLOAD_PATH != 'empty' |
| 52 | +# env: |
| 53 | +# API_URL: https://valid1-e2akhdekg6a7a2ch.canadacentral-01.azurewebsites.net/ |
| 54 | +# run: | |
| 55 | +# echo "Sending JSON payload to API" |
| 56 | +# response=$(curl -s -X POST "$API_URL" \ |
| 57 | +# -H "Content-Type: application/json" \ |
| 58 | +# --data-binary "@$JSON_PAYLOAD_PATH") |
| 59 | +# status=$(jq -r '.status' <<< "$response") |
| 60 | +# message=$(jq -r '.message' <<< "$response") |
| 61 | +# if [ "$status" != "passed" ]; then |
| 62 | +# echo "❌ Test Fail : $message" |
| 63 | +# exit 1 |
| 64 | +# fi |
| 65 | +# echo "✅ $message" |
0 commit comments