设置

  1. 从 WakaTime 账号设置中复制你的秘密 API 密钥。
  2. 把它保存为名为 WAKATIME_API_KEY 的仓库密钥。
  3. 把 wakatime 来源合并到你的提供方中,并把编码卡片加入 charts。
  4. 以环境变量的形式把密钥传给 Action。
profile-graphics.yml
provider:
  type: github
  user: octocat
  merge:
    - type: wakatime
      user: octocat

charts: [streak, langs, coding-time, coding-languages]
.github/workflows/profile-graphics.yml
- uses: mikhailkhorokhorin/profile-graphics@v1
  env:
    WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
  with:
    publish_branch: output
API 密钥可以读取你的全部编码活动。请把它保存在 WAKATIME_API_KEY 或 CI 密钥中,切勿提交到 profile-graphics.yml。

编码卡片

五张卡片都使用日历窗口和 calendar.timezone。无需密钥即可试用:profile-graphics demo 用演示数据渲染它们。

编码时间

编码时间

窗口内的总时间、活跃日平均值和最佳一天,下方是最近 days 天(7 到 90)的柱状图。

yaml
charts: [coding-time]
语言

语言

按编码时间排序的语言。coding_list.count 在全部四张列表卡片上显示 1 到 10 行。

yaml
charts: [coding-languages]
编辑器

编辑器

按编码时间排序的编辑器和 IDE。

yaml
charts: [coding-editors]
操作系统

操作系统

按编码时间排序的操作系统。

yaml
charts: [coding-os]
项目

项目

按编码时间排序的项目。

yaml
charts: [coding-projects]
shell
profile-graphics demo --charts coding-time,coding-languages,coding-editors --output dist/demo

与 GitHub 或 GitLab 合并

在 provider.merge 中,WakaTime 来源只提供编码时间。贡献、连续记录、语言和其他卡片仍来自你的主提供方,因此编码时长永远不会让贡献日历虚高。名字和头像也来自主提供方。

以 WakaTime 作为唯一来源

当 type: wakatime 作为主提供方时,一天中每开始一个小时的编码就计为一次贡献,因此连续贡献、日历和活动卡片会跟随你的编码时间,语言卡片按时间排列语言。名字和头像来自你的 WakaTime 个人资料。

yaml
provider:
  type: wakatime
  user: your-name

charts: [coding-time, streak, calendar, coding-projects]

calendar:
  mode: rolling

Wakapi 和兼容服务器

Wakapi 和其他提供 WakaTime 兼容 API 的服务器可通过 base_url 使用,Wakapi 的地址以 /api/compat/wakatime/v1 结尾。把服务器的 API 密钥放进 WAKATIME_API_KEY 或 token。

yaml
provider:
  type: wakatime
  user: your-name
  base_url: https://wakapi.dev/api/compat/wakatime/v1

限制

读取谁的数据由密钥决定;user 只用于给卡片命名。摘要按整个日历窗口请求,按 calendar.timezone 逐日获取。WakaTime 免费计划只保留较短的近期历史,因此较早的日期返回为空,较长的窗口可能被拒绝。编码时间柱状图最多需要最近 90 天的数据。