Building a Per-Repo Wiki: Automating Documentation with GitHub Actions
These articles are AI-generated summaries. Please check the original sources for full details.
Building a per-repo wiki that actually gets read
Engineer Vineeth N Krishnan developed a documentation workflow to stop being the ‘human shortcut’ for team deployment questions. The system utilizes the hidden .wiki.git repository structure that exists for every GitHub repository but often remains unused.
Why This Matters
Technical documentation often fails not because it is missing, but because it exists outside the developer’s primary workflow, leading to trust erosion when READMEs go stale. By treating documentation as code within a wiki/ folder, teams can apply PR reviews and version control to operational knowledge, ensuring that the ‘single source of truth’ is updated alongside the codebase rather than rotting in a separate UI.
Key Insights
- GitHub Wikis are separate git repositories accessible via the .wiki.git suffix, allowing for standard git clone and push operations.
- The rsync —delete command is critical in CI/CD pipelines to ensure the published wiki does not become a graveyard of deleted or outdated pages.
- Sparse checkouts in GitHub Actions allow workflows to pull only the documentation directory, optimizing performance for large-scale repositories.
- The ‘Answer, then write’ habit transforms Slack support threads into permanent documentation assets, reducing the cost of repeated developer interruptions.
Working Examples
GitHub Action to sync a local wiki/ folder to the repository’s hidden wiki git repo on every merge to main.
name: Publish Wiki
on:
push:
branches:
- main
paths:
- 'wiki/**'
- '.github/workflows/wiki-publish.yml'
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code repo
uses: actions/checkout@v6
with:
sparse-checkout: |
wiki
sparse-checkout-cone-mode: false
- name: Clone wiki repo
env:
GH_TOKEN: ${{ secrets.WIKI_TOKEN || secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
git clone "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.wiki.git" wiki-remote
- name: Sync wiki content
run: |
rsync -av --delete --exclude='.git' wiki/ wiki-remote/
- name: Commit and push
working-directory: wiki-remote
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "docs(wiki): sync from ${GITHUB_SHA:0:7}"
git push origin HEAD
Practical Applications
- Use case: Onboarding new developers by placing architecture and setup docs directly in the repo they are assigned to, reducing initial Slack pings.
- Pitfall: Using the default GITHUB_TOKEN often results in permission failures; a Personal Access Token (PAT) with repo-write scope is required for reliable wiki pushes.
- Use case: Implementing PR-reviewed documentation where senior engineers can catch stale facts or architectural inaccuracies before they are published.
- Pitfall: Over-engineering page hierarchy on day one; successful wikis grow organically from three core pages: Home, Setup, and Deployment.
References:
Continue reading
Next article
Stop Estimating, Start Measuring: A Bayesian Approach to Software Deadlines
Related Content
Deploying Scalable Flask Applications on AWS with GitHub CI/CD Pipelines
Architecting a Flask movie quiz app using EC2, RDS, and Nginx with an automated GitHub Actions ECR deployment pipeline for high availability.
Automating AquaChain: Building a Robust CI/CD Pipeline with GitHub Actions
Learn how AquaChain transitioned from manual SSH deployments to an automated GitHub Actions pipeline that completes in under 5 minutes.
From Chaos to Perfect Flow: Automating a 4,000 Repository GitLab Migration
A DevOps engineer successfully automated the migration of 4,000 GitLab repositories to Enterprise Edition, improving deployment frequency and reducing change failure rates.