How to add the contribution snake to your GitHub profile

The snake that eats your GitHub contribution graph is an animated SVG that a GitHub Actions workflow draws once a day. A workflow to copy, the README code with a dark-mode twin, how to change its colours, and why it stops updating after 60 quiet days.

Short answer: A README cannot run code, so a GitHub Actions workflow in your profile repository draws the snake once a day as an SVG file and saves it to the repository; the README then shows that file as a picture. Add the workflow, run it once from the Actions tab, and put a <picture> with a light and a dark version in your README.

The snake is the moving line that crawls across a contribution graph and eats the green squares. It looks like a live widget, but it is an ordinary animated SVG picture made fresh every day from your contribution calendar.

What do you need first?

A profile README: a public repository with exactly your username as its name (octocat/octocat), with a README.md at the top. GitHub shows that file on your profile. How to make a GitHub profile README covers it step by step.

Which workflow draws the snake?

The best-known one uses the open-source Platane/snk action. Its author's own example, with the time moved off the full hour, saved as .github/workflows/snake.yml in your profile repository:

name: generate animation

on:
  schedule:
    - cron: "20 4 * * *"
  workflow_dispatch:

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

    steps:
      - 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

      - 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 }}

What each part does:

PartWhat it does
cron: "20 4 * * *"Runs every day at 04:20 UTC
workflow_dispatchAdds a Run workflow button, for the first run
contents: writeLets the workflow save files to your repository
svg-only@v3Draws the snake as SVG (faster than the version that can also make a GIF)
outputsA light and a dark picture
The last stepSaves the pictures to a separate branch called output

Why 04:20 and not midnight? GitHub's docs say scheduled runs can be delayed at times of high load, especially at the start of every hour, so a time in the middle of the hour is safer.

How do you show the snake in your README?

After the first run (Actions, the workflow, Run workflow), the pictures exist on the output branch. Show them with a <picture>, so dark-mode visitors get the dark one; replace USER with your username:

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/USER/USER/output/github-contribution-grid-snake-dark.svg" />
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/USER/USER/output/github-contribution-grid-snake.svg" />
  <img alt="Contribution snake eating my GitHub contribution graph" src="https://raw.githubusercontent.com/USER/USER/output/github-contribution-grid-snake.svg" />
</picture>

Until the workflow has run once, those addresses do not exist and the README shows a broken picture. Dark mode images in a GitHub README explains the <picture> trick in more detail.

How do you change the snake's colours?

Add options to each output line, like a web address:

outputs: |
  dist/github-contribution-grid-snake.svg?color_snake=orange&color_dots=#ebedf0,#bfd6f6,#8dbdff,#64a1f4,#3c7dd9

color_snake is the snake. color_dots takes exactly five colours: an empty day first, then from the fewest contributions to the most. palette picks a preset: github, github-dark or github-light.

Why did my snake stop updating?

What you seeWhyFix
It stopped after about two monthsGitHub turns off scheduled workflows in a public repository after 60 days without activityActions, the workflow, Enable workflow
The run fails at the push stepThe workflow may not write to the repositoryKeep permissions: contents: write in the workflow
A broken picture in the READMEThe workflow has not run yet, or the username in the address is wrongRun it once by hand; check the address
The run starts lateScheduled runs wait at busy timesNothing to fix; it catches up

Where can you check this?

Can you add the snake without an outside action?

Profile README Studio has a contribution snake block with your choice of snake colour and six dot palettes (GitHub green, blue, purple, pink, Halloween and grey). It writes a workflow that draws the snake with its own code and the repository's own token, so no other action or server is involved, saves a light and a dark picture, and writes the README code for both. Run the workflow once from the Actions tab after adding it.

The tool

Do it in your browser.

GitHub

Profile README Studio

Build a GitHub profile README with a pixel-accurate preview, and badges, icons and cards the studio draws itself instead of outside servers.

Keep reading

More from the blog.

Every post