我想在我的 Github 上展示 这条可爱的蛇。
引用了此站点并使用基础分支“main”将其写入[MY_GITHUB_USERNAME]/.github/workflows/main.yml。
name: Generate Snake
on:
schedule:
# every 6 hours
- cron: "0 */6 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Platane/snk@master
id: snake-gif
with:
github_user_name: ${{ secrets.USERNAME }}
# these next 2 lines generate the files on a branch called "output". This keeps the main branch from cluttering up.
gif_out_path: dist/github-contribution-grid-snake.gif
svg_out_path: dist/github-contribution-grid-snake.svg
- run: git status
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
force: true
- uses: crazy-max/[email protected]
with:
# the output branch we mentioned above
target_branch: output
build_dir: dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
构建成功,然后切换'output'分支,当点击github-contribution-grid-snake.gif时,它显示很奇怪。
出了什么问题,我该怎么办?
参考很多其他博客并尝试..
我建议按照 snk github 存储库 中的官方说明获取最新说明,因为互联网上的其他信息可能已过时。您还可以在其 .github
文件夹中找到示例工作流程。
这是我自己测试的正确工作流程文件。它使用 snk 的 v3 而不是像您使用的 v2 。将其放在主分支上的
.github/workflows
文件夹中:
name: Snake generator
on:
push:
workflow_dispatch:
schedule:
- cron: "0 * * * *" # run every hour
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Create snake
uses: Platane/snk@v3
with:
# github user name to read the contribution graph from (**required**)
# using action context var `github.repository_owner` or specified user
github_user_name: ${{ github.repository_owner }}
# list of files to generate.
# one file per line. Each output can be customized with options as query string.
#
# supported options:
# - palette: A preset of color, one of [github, github-dark, github-light]
# - color_snake: Color of the snake
# - color_dots: Coma separated list of dots color.
# The first one is 0 contribution, then it goes from the low contribution to the highest.
# Exactly 5 colors are expected.
outputs: |
dist/github-snake.svg
dist/github-snake-dark.svg?palette=github-dark
dist/ocean.gif?color_snake=orange&color_dots=#bfd6f6,#8dbdff,#64a1f4,#4b91f1,#3c7dd9
- name: push github-contribution-grid-snake.svg to the output branch
uses: crazy-max/[email protected]
with:
target_branch: output
build_dir: dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
文件将在
snake-output
分支上生成。例如,我的 gif 看起来像这样: