DEV Community

Peakline Studio
Peakline Studio

Posted on

Keep Your GitHub Repo Docs Always Up-to-Date with This Free GitHub Action

We've all been there: you ship a feature, update the code, and then... the README still describes the old behavior. Three weeks later someone files an issue asking why the docs don't match. You fix the docs, ship another feature, and the cycle repeats.

Documentation drift is a solved problem — if you automate it.

In this tutorial I'll walk you through setting up a GitHub Action that automatically regenerates your README (or full API docs) every time you push to main. Zero config, one YAML file, done.

How It Works

The code-docs-action calls the Code Documentation Generator API on every push. The API analyzes your repository's source files using Claude AI and returns structured markdown documentation. The action then writes it to your target file and commits it back.

The API has a free tier (5 scans/month) — plenty for a side project with infrequent pushes, or for testing before upgrading.

Step 1: Get a Free RapidAPI Key

Sign up at RapidAPI and subscribe to the free BASIC plan. Copy your X-RapidAPI-Key from the API playground.

Step 2: Add the Secret to Your Repo

In your GitHub repository:

  • Go to Settings → Secrets and variables → Actions
  • Click New repository secret
  • Name: RAPIDAPI_KEY
  • Value: your RapidAPI key

Step 3: Create the Workflow File

Create .github/workflows/docs.yml in your repo:

name: Auto-generate documentation

on:
  push:
    branches: [main]
  workflow_dispatch:  # lets you trigger manually too

jobs:
  generate-docs:
    runs-on: ubuntu-latest
    permissions:
      contents: write  # needed to commit back to repo
    steps:
      - uses: actions/checkout@v4

      - name: Generate README
        uses: peaklineops/code-docs-action@v1.1
        with:
          rapidapi-key: ${{ secrets.RAPIDAPI_KEY }}
          doc-type: readme        # or "full" or "api-reference"
          output-file: README.md
Enter fullscreen mode Exit fullscreen mode

Commit and push — the action runs immediately.

What Gets Generated

The API reads your source files (ignoring node_modules, build artifacts, etc.) and generates documentation tailored to your codebase. For a typical project you'll get:

  • Project overview — what the project does, based on code structure
  • Installation instructions — inferred from package.json, pyproject.toml, etc.
  • Usage examples — based on exported functions and public APIs
  • API reference — for libraries, a full table of exports with descriptions

Configuration Options

The action has several inputs:

Input Default Description
doc-type readme readme, api-reference, or full
output-file README.md Where to write the output
commit-docs true Set false to just write the file (useful in PR checks)
commit-message docs: auto-update documentation [skip ci] The commit message

Generating API Docs Separately

If you want a separate API reference file in addition to your README:

steps:
  - uses: actions/checkout@v4

  - name: Generate README
    uses: peaklineops/code-docs-action@v1.1
    with:
      rapidapi-key: ${{ secrets.RAPIDAPI_KEY }}
      doc-type: readme
      output-file: README.md

  - name: Generate API Reference
    uses: peaklineops/code-docs-action@v1.1
    with:
      rapidapi-key: ${{ secrets.RAPIDAPI_KEY }}
      doc-type: api-reference
      output-file: docs/API.md
Enter fullscreen mode Exit fullscreen mode

Tip: Run on PRs Without Committing

For pull requests, you might want to preview generated docs without auto-committing:

on:
  pull_request:

jobs:
  preview-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Preview docs changes
        uses: peaklineops/code-docs-action@v1.1
        with:
          rapidapi-key: ${{ secrets.RAPIDAPI_KEY }}
          commit-docs: "false"   # generate only, don't commit

      - name: Show diff
        run: git diff README.md
Enter fullscreen mode Exit fullscreen mode

This lets reviewers see exactly how the docs will change before merging.

Wrapping Up

Once this is set up, documentation becomes a side effect of shipping code rather than a separate task. Your README reflects the current state of the codebase, always.

The action is open source: peaklineops/code-docs-action. Issues and PRs welcome.

The underlying API is on RapidAPI: Code Documentation Generator — free tier available, no credit card required.

Top comments (0)