Skip to main content

A CLI tool that visualizes GitHub contribution graphs as gamified GIFs

Project description

gh-space-shooter 🚀

Transform your GitHub contribution graph into an epic space shooter game!

Example Game

Usage

Onetime Generation

A web interface is available for on-demand GIF generation without installing anything locally.

GitHub Action

Automatically update your game GIF daily using GitHub Actions! Add this workflow to your repository at .github/workflows/update-game.yml:

name: Update Space Shooter Game

on:
  schedule:
    - cron: '0 0 * * *'  # Daily at midnight UTC
  workflow_dispatch:  # Allow manual trigger

permissions:
  contents: write

jobs:
  update-game:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 2  # This is crucial!

      - uses: czl9707/gh-space-shooter@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          output-path: 'game.gif'
          strategy: 'random'

Then display it in your README:

![My GitHub Game](game.gif)

Github Action V2 Change: : By default, the action amends the previous commit if it only contains the game file with the same commit message. This prevents repository bloat from daily commits. Set no-amend: true to disable this behavior. Need fetch-depth: 2 in actions/checkout@v6 to have this working.

Action Inputs:

  • github-token (required): GitHub token for fetching contributions
  • username (optional): Username to generate game for (defaults to repo owner)
  • output-path (optional): Where to save the animation, supports .gif or .webp (default: gh-space-shooter.gif)
  • strategy (optional): Attack pattern - column, row, or random (default: random)
  • fps (optional): Frames per second for the animation (default: 40)
  • no-amend (optional): Set to true to disable amending previous commits (default: false)
  • commit-message (optional): Commit message for the update

From PyPI

pip install gh-space-shooter

From Source

# Clone the repository
git clone https://github.com/yourusername/gh-space-shooter.git
cd gh-space-shooter

# Install with uv
uv sync

# Or with pip
pip install -e .

Setup

  1. Create a GitHub Personal Access Token:

  2. Set up your environment:

    # Copy the example env file
    touch .env
    echo "GH_TOKEN=your_token_here" >> .env
    

    Alternatively, export the token directly:

    export GH_TOKEN=your_token_here
    

CLI Usage

Generate Your Game Animation (GIF or WebP)

Transform your GitHub contributions into an epic space shooter!

# Basic usage - generates username-gh-space-shooter.gif
gh-space-shooter <username>

# Examples
gh-space-shooter torvalds
gh-space-shooter octocat

# Specify custom output filename (GIF or WebP)
gh-space-shooter torvalds --output my-epic-game.gif
gh-space-shooter torvalds -o my-game.webp

# Choose enemy attack strategy
gh-space-shooter torvalds --strategy row      # Enemies attack in rows
gh-space-shooter torvalds -s random           # Random chaos (default)

# Adjust animation frame rate
gh-space-shooter torvalds --fps 25            # Lower Frame rate, Smaller file size
gh-space-shooter torvalds --fps 40            # Default Frame rate, Larger file size

# Stop the animation earlier
gh-space-shooter torvalds --max-frame 200     # Stop after 200 frames

This creates an animated GIF showing:

  • Your contribution graph as enemies (more contributions = stronger enemies)
  • A Galaga-style spaceship battling through your coding history
  • Enemy attack patterns based on your chosen strategy
  • Smooth animations with randomized particle effects
  • Your contribution stats displayed in the console

Advanced Options

# Save raw contribution data to JSON
gh-space-shooter torvalds --raw-output data.json

# Load from previously saved JSON (saves API rate limits)
gh-space-shooter --raw-input data.json --output game.webp

# Combine options
gh-space-shooter torvalds -o game.webp -ro data.json -s column

Data Format

When saved to JSON, the data includes:

{
  "username": "torvalds",
  "total_contributions": 1234,
  "weeks": [
    {
      "days": [
        {
          "date": "2024-01-01",
          "count": 5,
          "level": 2
        }
      ]
    }
  ]
}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gh_space_shooter-2.0.4.tar.gz (11.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gh_space_shooter-2.0.4-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file gh_space_shooter-2.0.4.tar.gz.

File metadata

  • Download URL: gh_space_shooter-2.0.4.tar.gz
  • Upload date:
  • Size: 11.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gh_space_shooter-2.0.4.tar.gz
Algorithm Hash digest
SHA256 5f82d85f7d45ff2fa00dd6d42a31268f8aaa5fee8ce5f929e3c58d7a628be2f7
MD5 e30e6ee3fee84f0dba6b70d272121db2
BLAKE2b-256 58babeeb03998abd95a06e124ff204b5841bdd44b4031da294b94a4854ff9cef

See more details on using hashes here.

Provenance

The following attestation bundles were made for gh_space_shooter-2.0.4.tar.gz:

Publisher: publish.yml on czl9707/gh-space-shooter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gh_space_shooter-2.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for gh_space_shooter-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1e6dc2a853afa0c4cef9c5473f52f7001fa1d16b4df8085b0bd077f831b553ef
MD5 b4f0f97af337be117bb819c6a74f9553
BLAKE2b-256 b8a3b4968cfeccca7556812a06c5482cfe43f9e6ba49ad0697fbe8e5d2aaad1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gh_space_shooter-2.0.4-py3-none-any.whl:

Publisher: publish.yml on czl9707/gh-space-shooter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page