├── dingscore.json ├── README.md └── .github └── workflows └── update_push.yaml /dingscore.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # zju-score-push-template 2 | 你的成绩更新钉钉通知推送助手😋 3 | 4 | 使用了 [https://github.com/PeiPei233/ZJUScoreAssistant](https://github.com/PeiPei233/ZJUScoreAssistant) 5 | 6 | ## 使用帮助 7 | 8 | 首先使用本模板项目创建自己的 repo(点Use this template -> Create a new repository),为了您的信息安全,请将自己的 repo 设置为私有仓库(在 Settings -> General -> Danger Zone 中 change repository visibility)。 9 | 10 | 添加钉钉机器人(可选):在钉钉的新手体验群中选择设置,添加机器人,自定义。在安全设置中选择自定义关键词,并输入自定义关键词为 `成绩` ,勾选同意协议后点击完成,复制显示的 Webhook 作为接下来要用的钉钉机器人 Webhook。 11 | 12 | 然后在自己 repo 的 Settings -> Secrets and variables -> Actions 选择右侧 New repository secret,添加以下 Secrets: 13 | 14 | - `USERNAME`:你的浙大统一认证用户名 15 | - `PASSWORD`:你的浙大统一认证密码 16 | - `WEBHOOK`:你的钉钉机器人Webhook地址(可选) 17 | 18 | 请注意,是分别填写三条 Secrets,每条 Secret 的 Name 是冒号前的全大写单词,Value 应填写冒号后所提示的内容,且不要有多余的空格和回车。 19 | 20 | 不出意外,完成以上操作后,每隔五分钟会刷新一次,并推送更新的成绩。你也可以在 Actions -> Auto Push Updated Score Info 中手动运行或 Disable/Enable workflow。 21 | 22 | 如果想修改间隔时间,可以修改 `.github/workflows/update_push.yml` 中的 `schedule` 字段,将其中 `- cron: '*/5 * * * *'` 中的数字 5 改为你想要的数字(分钟数)即可。 23 | 24 | 由于 GitHub 限制,最终间隔时间不一定是设定的间隔时间,导致推送有延迟,并且私有仓库使用免费 Actions 的次数受限:[关于 GitHub Actions 的计费](https://docs.github.com/zh/billing/managing-billing-for-github-actions/about-billing-for-github-actions),不过完全够考试周使用。有能力最好还是将推送服务挂在自己的服务器上。 25 | 26 | 由于钉钉限制了机器人的推送频率,因此在第一次刷新时可能会出现只推送了部分成绩的情况,不影响后续使用。 27 | 28 | 已知存在的 bug:二级制(如水测等)成绩也会计入均绩中,重修、弃修错误计算均绩等,导致均绩计算不准确。 29 | -------------------------------------------------------------------------------- /.github/workflows/update_push.yaml: -------------------------------------------------------------------------------- 1 | name: Auto Push Updated Score Info 2 | 3 | on: 4 | schedule: 5 | - cron: '*/5 * * * *' 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | permissions: 13 | contents: write 14 | 15 | steps: 16 | 17 | - uses: actions/checkout@v3 18 | 19 | - name: Setup Python Environment 20 | uses: actions/setup-python@v3 21 | with: 22 | python-version: '3.10' 23 | 24 | - name: Get Score Assistant Repo 25 | run: git clone https://github.com/PeiPei233/ZJUScoreAssistant.git 26 | 27 | - name: Install Python Dependencies 28 | run: pip install -r ZJUScoreAssistant/requirements.txt 29 | 30 | - name: Run Python Script 31 | run: | 32 | echo "{\"username\": \"$USERNAME\", \"password\": \"$PASSWORD\", \"url\": \"$WEBHOOK\"}" > database.json 33 | timeout 20s python ZJUScoreAssistant/zjuscore.py -u -dn || true 34 | env: 35 | USERNAME: ${{ secrets.USERNAME }} 36 | PASSWORD: ${{ secrets.PASSWORD }} 37 | WEBHOOK: ${{ secrets.WEBHOOK }} 38 | 39 | - name: Check if dingscore.json is updated 40 | id: checkjson 41 | run: | 42 | git diff --exit-code dingscore.json || echo "changed=true" >> $GITHUB_OUTPUT 43 | 44 | - name: Push generated dingscore.json 45 | run: | 46 | git config --local user.email "action@github.com" 47 | git config --local user.name "GitHub Action" 48 | git checkout main 49 | git add dingscore.json 50 | git commit -m "Automatically update dingscore.json" 51 | git push origin main 52 | env: 53 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 54 | if: steps.checkjson.outputs.changed 55 | --------------------------------------------------------------------------------