Github如何展示贪吃蛇动画与掘金数据

一、效果展示

项目制作参考:github.com/HuiDBK

Github数据与掘金数据

Github贡献活跃度-贪吃蛇动画

二、创建个人简介的Github项目

创建一个跟自己名称相同的Github项目,这是一个特殊的个人简介项目,用户访问你的github首页时则会展示这个项目的 REAME.md 文档里内容。

三、修改readme.md 文档

Github统计数据制作

html 复制代码
<table border=0>
  <tr>
    <td><img src="https://github-readme-stats.vercel.app/api?username=huidbk&show_icons=true&count_private=true&theme=vue-light&hide_border=true" alt="HuiDBK's GitHub stats" style="zoom:100%;" align="left"/></td>
    <td><img src="https://4sdvg7tqbv.us.aircode.run/juejin?uid=817692384431470&hide_border=true" alt="HuiDBK的掘金数据" style="zoom:100%;" align="left"/></td>
  </tr>
</table>

这里引入html代码的table标签来制作表格展示

如下是Github的数据统计的链接

github-readme-stats.vercel.app/api?usernam...

只要把username={换成你自己的Github用户名}

掘金数据制作

4sdvg7tqbv.us.aircode.run/juejin?uid=...

把uid={换成你掘金账号主页的uid}

就会展示出掘金的一些数据

Github项目置顶制作

html 复制代码
<p>
  <a href="https://github.com/HuiDBK/py-tools">
        <img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=huidbk&repo=py-tools&theme=vue-light" />
  </a>
   <a href="https://github.com/HuiDBK/WordSprite">
        <img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=huidbk&repo=WordSprite&theme=vue-light" />
  </a>
</p>

username={Github用户名}&repo={项目名称}

Github活跃度贪吃蛇动画制作

这个制作麻烦一些,需要通过Github的action来生成贪吃蛇动态图

  1. 在这个与自己用户名一样的项目中新建 workflow

输入如下生成贪吃动画的工作流

yml 复制代码
name: generate-snake

on:
  # 每 12 小时自动运行一次
  schedule:
    - cron: "0 */12 * * *"

  # 允许手动触发执行
  workflow_dispatch:

  # 每当push到master分支时自动执行
  push:
    branches:
    - master



jobs:
  generate:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      # generates a snake game from a github user (<github_user_name>) contributions graph, output a svg animation at <svg_out_path>
      - name: Generate github-contribution-grid-snake.svg
        uses: Platane/snk/svg-only@v2
        with:
          github_user_name: ${{ github.repository_owner }}
          outputs: |
            dist/github-contribution-grid-snake.svg
            dist/github-contribution-grid-snake-dark.svg?palette=github-dark
      # push the content of <build_dir> to a branch
      # the content will be available at https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file> , or as github page
      - name: Push github-contribution-grid-snake.svg to the output branch
        uses: crazy-max/ghaction-github-pages@v2.6.0
        with:
          target_branch: output
          build_dir: dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

查看是否运行成功

如果出现如上情况,说明 action 的 workflow 的权限不足,可以到项目中 settings->actions->general 中调整下 Workflow permissions 权限就可以了

然后重新运行,成功运行就会在项目中自动新建一个 output 分支然后生成贪吃蛇的动画图

最后就是在readme文档中引用这张动态图就行

markdown 复制代码
![HuiDBK's github activity graph](https://raw.githubusercontent.com/HuiDBK/HuiDBK/output/github-contribution-grid-snake.svg)

换成自己Github用户名就行

raw.githubusercontent.com/HuiDBK/HuiD...

四、参考

相关推荐
llz_1122 小时前
web-第二次课后作业
前端·后端·web
cup118 小时前
[Full Clock 技术复盘] 一、浏览器前端如何实现百毫秒级时间校准?时间 API 推荐、模拟 NTP 算法原理及局限
typescript·开源·api·时钟·时间同步
红尘散仙8 小时前
我把终端小说阅读器接上了 AI Agent:TRNovel 现在能用 skill 生成书源了
人工智能·后端·rust
卷毛的技术笔记9 小时前
告别硬编码!Spring AI Alibaba 实现 AI Agent 智能工具调用(Tool Calling)
java·人工智能·后端·python·spring·ai编程
会编程的土豆10 小时前
Go 语言反射(Reflection)详解
开发语言·后端·golang
喵个咪10 小时前
GoWind Toolkit Go后端代码生成 完整全流程实战
后端·go·orm
冬奇Lab10 小时前
每日一个开源项目(第118篇):SkillOpt - 像训练神经网络一样优化 LLM Agent 的技能
人工智能·开源·agent
basketball61611 小时前
Go 语言从入门到进阶:4. 数组和MAP使用方法总结
开发语言·后端·golang
qq_25183645711 小时前
SpringBoot+Vue 共享电池柜管理系统 完整实现 前后端分离项目实战 完整代码
vue.js·spring boot·后端
妄想出头的工业炼药师11 小时前
GS slam mono
算法·开源