From 4ec2f6de73ebaa240d4642917ecde896b6073d3a Mon Sep 17 00:00:00 2001 From: XUKUNYUAN Date: Mon, 8 Jul 2024 23:32:22 +0800 Subject: [PATCH] add new result json --- .github/workflows/rust.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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