在你想要放置 Readme-WakaTime 的位置中放置以下注釋,這將作為程式的入口
<!--START_SECTION:waka-->
<!--END_SECTION:waka-->
存取 WakaTime 官方網站註冊並登入,你需要找到對應的 IDE/編輯器 外掛,目前(2023.7.3)官方外掛支援以下軟體
本篇教學以 VS Code 為例
在 VS Code 主介面按下 Ctrl+Shift+P 調出命令面板,輸入Install,選擇Install Extension選項並回車
之後在擴充套件介面中輸入 WakaTime
並安裝該外掛
WakaTime api
並回車Secret API Key
選項複製API設定好後這樣的,如圖所示
.github/workflows
結構的資料夾workflows
資料夾下新建一個yml檔案,注意不要建錯了,很多人都會建錯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 }}
如果出現該對話方塊,那麼請點選Pull後再次Commit&Push
注:如果出現如下錯誤,那麼你需要檢查README.md檔案是否寫入了那兩行註釋,錯誤資訊如下
File "/waka-readme-stats/main.py", line 221, in <module>
[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檔案中的合適位置寫入這兩行註釋
<!--START_SECTION:waka-->
<!--END_SECTION:waka-->
設定完成並執行成功後,回到你的個人倉庫主頁,你就會發現!我去,真甜蜜炫酷啊啊啊啊啊!!!!對不起,請允許我發電一下(深情~:D)
至此,所有的設定我們都做完了。如果你想對這些進行擴充套件,那麼你可以參考我翻譯的檔案,裡面記錄了各個標誌欄位的作用和顯示與否,也歡迎專業翻譯人員對檔案翻譯進行語言改進,非常感謝!
WakaTime Readme Stats-開源專案翻譯 - sarexpine - 部落格園 (cnblogs.com)