|
65 | 65 | with: |
66 | 66 | name: aoai-response-test # folder name visible in the UI |
67 | 67 | path: aoai-test-result.json |
| 68 | + |
| 69 | + # 6 – parse JSON and inject into README |
| 70 | + - name: Parse results and update README |
| 71 | + shell: bash |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + run: | |
| 75 | + # read the values |
| 76 | + PASS=$(jq -r .pass_fail aoai-test-result.json) |
| 77 | + CODE=$(jq -r .error_code aoai-test-result.json) |
| 78 | + DATE=$(jq -r .test_run_date aoai-test-result.json) |
| 79 | +
|
| 80 | + # build the markdown snippet |
| 81 | + read -r -d '' SNIPPET << EOF |
| 82 | + <!-- AOAI-RESULTS-START --> |
| 83 | + ## ⚙️ Last Azure OpenAI Test |
| 84 | + - **Date:** $DATE |
| 85 | + - **Result:** $PASS |
| 86 | + - **Exit code:** $CODE |
| 87 | + <!-- AOAI-RESULTS-END --> |
| 88 | + EOF |
| 89 | +
|
| 90 | + # replace the section between the markers in README.md |
| 91 | + # (assumes README.md already has those two markers somewhere) |
| 92 | + awk -v new="$SNIPPET" ' |
| 93 | + /<!-- AOAI-RESULTS-START -->/ { print new; skip=1; next } |
| 94 | + /<!-- AOAI-RESULTS-END -->/ { print; skip=0; next } |
| 95 | + skip { next } |
| 96 | + { print } |
| 97 | + ' README.md > README.tmp && mv README.tmp README.md |
| 98 | +
|
| 99 | + # 7 – commit & push the updated README back |
| 100 | + - name: Commit updated README |
| 101 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 102 | + with: |
| 103 | + commit_message: chore: update README with latest AOAI test results |
| 104 | + file_pattern: README.md |
| 105 | + author_name: GitHub Actions |
| 106 | + |
| 107 | + branch: ${{ github.ref_name }} |
0 commit comments