|
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 and push updated README |
101 | | - shell: bash |
102 | | - env: |
103 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
104 | | - run: | |
105 | | - # ensure we can push back to the repo |
106 | | - git config user.name "github-actions[bot]" |
107 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
108 | | - git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
109 | | -
|
110 | | - # only commit if there are changes |
111 | | - if git diff --quiet README.md; then |
112 | | - echo "No README changes to commit." |
113 | | - else |
114 | | - git add README.md |
115 | | - git commit -m "chore: update README with latest AOAI test results" |
116 | | - git push origin ${{ github.ref_name }} |
117 | | - fi |
0 commit comments