Skip to content

Snake

Snake #1034

Workflow file for this run

# This GitHub Actions workflow is named "Snake" and generates a snake game SVG based on a GitHub user's contribution graph.
# The workflow is triggered by three events:
# 1. Automatically every 24 hours using a cron schedule.
# 2. Manually through the GitHub Actions interface.
# 3. On every push to the master branch.
# The workflow has read permissions for the contents of the repository.
# The workflow consists of a single job named "generate" which has write permissions for the contents.
# The job runs on the latest version of Ubuntu and has a timeout of 5 minutes.
# The job includes the following steps:
# 1. Harden Runner: Uses the step-security/harden-runner action to enhance security by auditing egress traffic.
# 2. Generate SVG: Uses the Platane/snk/svg-only action to generate the snake game SVGs based on the GitHub user's contribution graph.
# 3. Push SVG to Output Branch: Uses the crazy-max/ghaction-github-pages action to push the generated SVGs to the "output" branch,
# making them available as raw content or as a GitHub page. The GITHUB_TOKEN secret is used for authentication.
name: Snake
on:
# run automatically every day at midnight
schedule:
- cron: '0 0 * * *'
# allows to manually run the job at any time
workflow_dispatch:
# run on every push on the master branch
push:
branches:
- master
- main
permissions:
contents: read
concurrency:
group: snake-${{ github.ref }}
cancel-in-progress: false
jobs:
generate:
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
# generates a snake game from a github user (<github_user_name>) contributions graph, output a svg animation at <svg_out_path>
- name: Harden Runner
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
with:
egress-policy: audit
- name: generate github-contribution-grid-snake.svg
uses: Platane/snk/svg-only@e2cedf76a2c05b25d09a6428ded69727b497a700 # v3.4.1
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@df5cc2bfa78282ded844b354faee141f06b41865 # v4.2.0
with:
target_branch: output
build_dir: dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}