Github首页添加贪吃蛇动画

本文最后更新于:2024年7月7日 上午

Github 首页添加贪吃蛇动画

一、前言

动画所需要的代码是运行到Github Actions

GitHub Actions 是一个用于自动化软件工作流程的平台,包括构建、测试和部署代码。它允许开发人员为软件开发过程的不同阶段创建自定义工作流程,并自动执行重复的任务。GitHub Actions 可以集成到 GitHub 存储库中,并可以被各种事件(如拉取请求、提交和发布)触发。使用 GitHub Actions,开发人员可以轻松协作、减少错误并节省时间。它支持广泛的编程语言,并提供了许多预构建的操作 actionsGitHub Marketplace 中使用。

二、创建 Action

需在 Github 账户同名的仓库下创建 Action,点击 New workflow -> Configure。

点击 Configure 后显示如下界面:

三、配置脚本

将下面代码复制粘贴到yml文件中,然后点击Commit changes部署脚本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# GitHub Action for generating a contribution graph with a snake eating your contributions.

name: Generate Snake

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2.3.4

- name: Generate Snake
uses: Platane/snk@master
id: snake-gif
with:
github_user_name: ${{ github.repository_owner }}
gif_out_path: ./assets/github-contribution-grid-snake.gif
svg_out_path: ./assets/github-contribution-grid-snake.svg

- name: Push to GitHub
uses: EndBug/add-and-commit@v7.2.1
with:
branch: main
message: 'Generate Contribution Snake'

四、设置 workflow 权限

settings-> Actions -> General -> Read and write permissions设置读写权限

五、运行 workflow

点击Actions到刚才配置好的workflow,点击Run workflow安全运行脚本。

六、引入 svg 动画

1
![](https://raw.githubusercontent.com/你的 GitHub 名/你的 GitHub 名/main/assets/github-contribution-grid-snake.svg)

“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭ ”

微信二维码

微信支付

支付宝二维码

支付宝支付

Github首页添加贪吃蛇动画
https://blog.jishuqin.cn/posts/c4d5e6f7/
作者
顾梦
发布于
2023年6月11日
更新于
2024年7月7日
许可协议