Keeping repository documentation up to date is a task that often gets deprioritized as codebases evolve. To solve this, I recently automated our documentation workflow across several application repositories using OpenWiki.
For our initial rollout, we opted to skip the OpenWiki visualizer and focus strictly on generating and committing updated .md files directly inside the repositories whenever changes land on our staging branch.
Here is how I designed and built this pipeline using GCP Cloud Build, Terraform, and Gemini Enterprise.
ποΈ Architecture & Security Setup
When implementing LLM-powered tools into CI/CD pipelines, cost tracking and access control are critical considerations.
- Dedicated GCP Project: Since OpenWiki doesn’t currently support custom resource labels on API calls (Iβve submitted a feature request for this on the OpenWiki repo), I isolated this setup into its own dedicated GCP project. This ensures clean cost attribution and isolated billing metrics.
- Model Selection: The pipeline uses the
gemini-enterprise 3.6-flashmodel for lightweight, fast, and cost-effective documentation generation. - Least Privilege IAM: The project runs on a dedicated Service Account with strictly scoped permissions required only for Cloud Build execution and API access.
π οΈ Step-by-Step Implementation
1. Custom Docker Container
OpenWiki needs both its CLI dependencies and Git to interact with the repository. I built a lightweight, specialized Docker image containing both openwiki and git-cli to keep the pipeline execution fast.
2. Infrastructure as Code (Terraform)
Using Terraform, I provisioned:
- The isolated GCP Project and enabled required APIs (Vertex AI / Cloud Build).
- The dedicated Service Account and IAM roles following the principle of least privilege.
- Inline GCP Cloud Build triggers attached to our application repositories.
3. The Cloud Build Pipeline
The Cloud Build trigger fires automatically whenever code is pushed to or created on our staging branch. The pipeline step checks out the target branch, runs OpenWiki, and commits the updated .md documentation back to origin.
Here is the core inline build step used in the Cloud Build trigger:
| |
(Note: SSH key provisioning and GitHub authentication details are handled separately outside of this build step.)
π― Key Takeaways
Zero Developer Friction: Developers don’t need to manually run CLI commands to update docsβit happens automatically in CI/CD on staging pushes.
Cost Isolation: Until OpenWiki supports granular labeling natively, running LLM tasks in a dedicated GCP project is a clean workaround for cost management.
Preventing Infinite Loops: Adding [skip ci] to the automated commit message prevents Cloud Build from recursively triggering itself on doc updates.
