注:本篇文章首发于 博客园sarexpine 为保持阅读的舒适性,可以选择移步至 博客园sarexpine 阅读,日后的文章将首发于 博客园sarexpine 平台,谢谢!
在你想要放置 Readme-WakaTime 的位置中放置以下注释,这将作为程序的入口
访问 WakaTime 官方网站注册并登录,你需要找到对应的 IDE/编辑器 插件,目前(2023.7.3)官方插件支持以下软件
本篇教程以 VS Code 为例
配置好后这样的,如图所示
name: Waka Readme
on:
schedule:
# Runs at 12am IST
- cron: '30 18 * * *'
workflow_dispatch:
jobs:
update-readme:
name: Update Readme with Metrics
runs-on: ubuntu-latest
steps:
- uses: anmol098/waka-readme-stats@master
with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
注:如果出现如下错误,那么你需要检查README.md文件是否写入了那两行注释,错误信息如下
File "/waka-readme-stats/main.py", line 221, in
[29](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:30) run(main())
[30](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:31) File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
[31](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:32) return runner.run(main)
[32](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:33) ^^^^^^^^^^^^^^^^
[33](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:34) File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
[34](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:35) return self._loop.run_until_complete(task)
[35](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:36) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[36](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:37) File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
[37](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:38) return future.result()
[38](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:39) ^^^^^^^^^^^^^^^
[39](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:40) File "/waka-readme-stats/main.py", line 208, in main
[40](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:41) stats = await get_stats()
[41](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:42) ^^^^^^^^^^^^^^^^^
[42](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:43) File "/waka-readme-stats/main.py", line 163, in get_stats
[43](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:44) data = await DM.get_remote_json("waka_all")
[44](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:45) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[45](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:46) File "/waka-readme-stats/manager_download.py", line 202, in get_remote_json
[46](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:47) return await DownloadManager._get_remote_resource(resource, None)
[47](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:48) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[48](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:49) File "/waka-readme-stats/manager_download.py", line 193, in _get_remote_resource
[49](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:50) raise Exception(f"Query '{res.url}' failed to run by returning code of {res.status_code}: {res.json()}")
[50](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:51)Exception: Query '[https://wakatime.com/api/v1/users/current/all_time_since_today?api_key=***](https://wakatime.com/api/v1/users/current/all_time_since_today?api_key=***)' failed to run by returning code of 202: {'data': {'is_up_to_date': False, 'range': {'start': '2023-07-01T16:00:00Z', 'start_date': '2023-07-02', 'start_text': 'Yesterday', 'end': '2023-07-03T15:59:59Z', 'end_date': '2023-07-03', 'end_text': 'Today', 'timezone': 'Asia/Shanghai'}, 'timeout': 15, 'percent_calculated': 0, 'total_seconds': 0, 'text': '0 secs', 'decimal': '0.00', 'digital': '0:00'}, 'message': 'Calculating stats for this user. Check back later.'}
[51](https://github.com/MagicCD/MagicCD/actions/runs/5444806464/jobs/9903159455#step:3:52)sys:1: RuntimeWarning: coroutine 'AsyncClient.get' was never awaited
解决方法:在README.md文件中的合适位置写入这两行注释
设置完成并执行成功后,回到你的个人仓库主页,你就会发现!我去,真甜蜜炫酷啊啊啊啊啊!!!!对不起,请允许我发电一下(深情~:D)
至此,所有的设置我们都做完了。如果你想对这些进行扩展,那么你可以参考我翻译的文档,里面记录了各个标志字段的作用和显示与否,也欢迎专业翻译人员对文档翻译进行语言改进,非常感谢!
WakaTime Readme Stats-开源项目翻译 - sarexpine - 博客园 (cnblogs.com)