Skip to content

snk

根据 GitHub 用户的贡献图生成贪吃蛇游戏。

ref-reporef-online-toolref-official-docref-dependent-action

用法

  1. 在仓库中创建一个 .github/workflows/ 目录。
  2. 添加一个 snk.yml 文件,内容如下:
yaml
name: generate animation

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

  # 允许手动运行
  workflow_dispatch:

  # 主分支代码更新时运行
  push:
    branches:
      - main

jobs:
  generate:
    permissions:
      contents: write
    runs-on: ubuntu-latest
    timeout-minutes: 5

    steps:
      # 生成一个贪吃蛇动画来自 GitHub 用户的贡献图,输出一个 svg 动画到 <svg_out_path>
      - name: generate github-contribution-grid-snake.svg
        uses: Platane/snk/svg-only@v3
        with:
          github_user_name: ${{ github.repository_owner }}
          outputs: |
            dist/github-contribution-grid-snake.svg
            dist/github-contribution-grid-snake-dark.svg?palette=github-dark

      # 推送 <build_dir> 内容到分支
      # 内容将会被推送到 https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file> 或者作为 github page
      - name: push github-contribution-grid-snake.svg to the output branch
        uses: crazy-max/ghaction-github-pages@v3.1.0
        with:
          target_branch: output
          build_dir: dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1. 在你的仓库中,创建或编辑 README.md 文件,以包含:
markdown
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/[Owner]/[Repo]/output/github-contribution-grid-snake-dark.svg">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/[Owner]/[Repo]/output/github-contribution-grid-snake.svg">
  <img alt="github 贡献图贪吃蛇动画" src="https://raw.githubusercontent.com/[Owner]/[Repo]/output/github-contribution-grid-snake.svg">
</picture>

参数

点击显示/关闭参数

名称类型必填默认值参数描述更多描述
ref-actions
github_user_namestringtrueGitHub 用户名
github_tokenstringGitHub Token
outputsarray生成的文件列表文件生成规则参考 outputs

示例

markdown
<!-- platane -->
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/platane/platane/output/github-contribution-grid-snake-dark.svg">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/platane/platane/output/github-contribution-grid-snake.svg">
  <img alt="github 贡献图贪吃蛇动画" src="https://raw.githubusercontent.com/platane/platane/output/github-contribution-grid-snake.svg">
</picture>
github 贡献图贪吃蛇动画

Readme Widget Hub (v4.1.4) MIT Licensed