diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f886794..fbd386e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -29,4 +29,28 @@ jobs: id: autograding with: outputFile: .github/result/check_result.json + - name: Generate summary JSON + run: | + outfile=".github/result/outfile" + summary_file=".github/result/summary.json" + # 提取需要的值 + total_exercations=$(jq '.statistics.total_exercations' $outfile) + total_succeeds=$(jq '.statistics.total_succeeds' $outfile) + user_name=$(jq -r '.user_name' $outfile) + + # 生成新的 JSON 内容 + new_json=$(jq -n \ + --arg channel "github" \ + --argjson courseId 1558 \ + --arg ext "aaa" \ + --arg name "$user_name" \ + --argjson score "$total_succeeds" \ + --argjson totalScore "$total_exercations" \ + '{channel: $channel, courseId: $courseId, ext: $ext, name: $name, score: $score, totalScore: $totalScore}') + + # 保存新的 JSON 文件 + echo "$new_json" > $summary_file + + # 打印新的 JSON 文件到终端 + cat $summary_file