5
5
branches : [ main ]
6
6
paths-ignore :
7
7
- ' README.md'
8
- # - '.github/**'
9
8
pull_request :
10
9
branches : [ main ]
11
10
workflow_dispatch :
@@ -30,42 +29,38 @@ jobs:
30
29
id : autograding
31
30
with :
32
31
outputFile : .github/result/check_result.json
33
- deploy :
34
- name : Deploy to pages
35
- needs : build
36
- runs-on : ubuntu-latest
37
- steps :
38
- - uses : actions/checkout@v3
39
- continue-on-error : true
40
- with :
41
- ref : ' gh-pages'
42
- - name : Save Log File
43
- run : |
44
- mkdir autograding_logs
45
- cd autograding_logs
46
- if [ -f "../latest.json" ]; then
47
- cp ../latest.json older.json
48
- else
49
- echo "{}" > older.json
50
- fi
51
- FILE_NAME=`date +%Y_%m_%d_%H_%M_%S`.txt
52
- echo -ne "${{ needs.build.outputs.details }}\n" > $FILE_NAME
53
- echo -ne "Points: ${{ needs.build.outputs.points }}" >> $FILE_NAME
54
- cat older.json | jq ".default |= \"$FILE_NAME\"" > latest.json
55
- rm older.json
56
- echo -ne "# Got Points\n" > README.md
57
- echo "" >> README.md
58
- - name : Make points svg
59
- uses : markpatterson27/points-bar@v1
60
- with :
61
- points : ' ${{ needs.build.outputs.points }}'
62
- path : ' autograding_logs/points-badge.svg'
63
- type : ' badge'
64
- - name : GitHub Pages
65
- uses : crazy-max/ghaction-github-pages@v3
66
- with :
67
- target_branch : gh-pages
68
- build_dir : autograding_logs
69
- keep_history : true
70
- env :
71
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
+ - name : Generate summary JSON
33
+ run : |
34
+ outfile=".github/result/check_result.json"
35
+ summary_file=".github/result/summary.json"
36
+
37
+ # 提取需要的值
38
+ total_exercations=$(jq '.statistics.total_exercations' $outfile)
39
+ total_succeeds=$(jq '.statistics.total_succeeds' $outfile)
40
+ github_user="${{ github.actor }}"
41
+
42
+ # 生成新的 JSON 内容
43
+ new_json=$(jq -n \
44
+ --arg channel "github" \
45
+ --argjson courseId 1558 \
46
+ --arg ext "aaa" \
47
+ --arg name "$github_user" \
48
+ --argjson score "$total_succeeds" \
49
+ --argjson totalScore "$total_exercations" \
50
+ '{channel: $channel, courseId: $courseId, ext: $ext, name: $name, score: $score, totalScore: $totalScore}')
51
+
52
+ # 保存新的 JSON 文件
53
+ echo "$new_json" > $summary_file
54
+
55
+ # 打印新的 JSON 文件到终端
56
+ cat $summary_file
57
+ - name : Post summary JSON to remote API
58
+ run : |
59
+ summary_file=".github/result/summary.json"
60
+
61
+ # 发送 POST 请求
62
+ curl -X POST "https://api.learningcamp.cn/web/api/courseRank/createByThird" \
63
+ -H "accept: application/json;charset=utf-8" \
64
+ -H "Content-Type: application/json" \
65
+ -d "$(cat $summary_file)" \
66
+ -v
0 commit comments