Github活跃度贪吃蛇动画制作
这个制作麻烦一些,需要通过Github的action来生成贪吃蛇动态图
- 在这个与自己用户名一样的项目中新建 workflow
- (xiaopao6 (棚子咯) (github.com))
编辑
编辑
编辑
输入如下生成贪吃动画的工作流
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文档中引用这张动态图就行

复制
换成自己Github用户名就行
raw.githubusercontent.com/xiaopao6/xi…
编辑