让你的 GitHub 贡献图在重力作用下掉落,与自定义文字碰撞,生成精美的 SVG 动画。
本项目灵感来自 Orta Therox 的创意。感谢 Orta 为开源社区做出的杰出贡献!
- name: Generate Gravity SVG
uses: flycran/github-gravity@v1
with:
username: Orta
text: Orta Therox
output-path: gravity.svg| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
username |
✅ | - | GitHub 用户名,用于获取贡献数据 |
text |
❌ | username 的值 |
作为碰撞障碍物的文字 |
output-path |
❌ | gravity.svg |
SVG 输出路径 |
font-size |
❌ | 80 |
碰撞文字大小 |
sample-rate |
❌ | 4 |
轨迹采样率(越大文件越小,动画越不流畅) |
shape |
❌ | circle |
贡献方块的形状(circle 或 square) |
text-top |
❌ | 50 |
文字距离世界顶部的距离,控制文字垂直位置 |
background-color |
❌ | transparent |
SVG 背景颜色(CSS 颜色值) |
text-color |
❌ | black |
碰撞文字颜色(CSS 颜色值) |
| 输出 | 说明 |
|---|---|
svg-path |
生成的 SVG 文件路径 |
name: Generate Contribution Gravity
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
jobs:
gravity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: flycran/github-gravity@v1
with:
username: Orta
text: Orta Therox
output-path: deploy/gravity.svg
- uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./deploy
publish_branch: output
keep_files: false
force_orphan: truebun installnpm run test修改 src/ 下的代码后,需要重新打包:
npm run bundlenpx @github/local-action . src/main.ts .env查看 Versioning 了解 GitHub Actions 版本管理。