Skip to content

GitHub Action that visualizes your codebase growth — counts lines of code per commit and auto-updates an SVG chart you can embed in your README

License

Notifications You must be signed in to change notification settings

botforge-pro/loc-graph-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LOC Graph Action

Tests

GitHub Action that scans your repository's commit history, calculates lines of code (LOC) for each commit, and produces an SVG chart showing how LOC changes over time. The generated SVG and a JSON cache are automatically committed back to the repository, allowing you to embed the chart directly in your README.

Quick Setup

Create a workflow file .github/workflows/loc-graph.yml:

name: LOC graph

on:
  schedule:
    - cron: '0 0 * * *'  # Daily at midnight
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-loc-graph:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: botforge-pro/loc-graph-action@main

After the workflow has run, add the following HTML snippet to the end of your README to display the LOC graph with automatic theme switching:

### Lines of Code Over Time
<picture>
  <source media="(prefers-color-scheme: dark)" srcset=".github/loc-history-dark.svg">
  <source media="(prefers-color-scheme: light)" srcset=".github/loc-history-light.svg">
  <img src=".github/loc-history.svg" alt="Lines of code over time">
</picture>

Advanced Setup

name: LOC graph

on:

  # Trigger on every push (mostly for testing)
  push:
    branches: [ main, master ]
  
  # Trigger daily at midnight (recommended for active projects)
  schedule:
    - cron: '0 0 * * *'

  # Allow manual triggering from the Actions tab
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-loc-graph:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout full history
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Generate LOC graph
        uses: botforge-pro/loc-graph-action@main
        with:
          output_json: "docs/data/loc-cache.json"
          fallback_theme: dark  # Theme for .github/loc-history.svg
          date_format: "%Y-%m-%d"  # 2024-03-15
          time_format: "%I:%M %p"  # 03:45 PM
          exclude: ".cache,assets"  # Additional names to exclude

Live example

This repository uses its own action to track LOC over time:

Lines of code over time

About

GitHub Action that visualizes your codebase growth — counts lines of code per commit and auto-updates an SVG chart you can embed in your README

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •