logo
Published on

Project Docs 1. Source in the Repo, Copy in Google Docs

Authors
  • avatar
    Name
    seren-wib
    Twitter
Contents

Part 1 of the series. The full template picture is in Project Docs 0.

0. Introduction

Stage documents such as the plan, the SRS and the SDD are read by teammates and the professor in Google Docs, while the source that code and tests point to has to live in the Repository. Syncing by hand always drifts, so I picked one source and let a machine make the copy.

In restaurant terms, I first wrote the menu straight onto the dining-room board and kept only notes in a notebook. Then I switched to editing only the kitchen's recipe book and letting a copy clerk, holding a one-time pass, paste a fresh copy into the same spot on the board. The recipe book is the repo's Markdown as the Single source of truth, the copy clerk is a GitHub Actions Workflow, the one-time pass is the Short-lived token that OIDC and Workload Identity Federation hand out, and the board is Google Docs.

What I did: on October 17 I started with Google Docs as the source and flipped to repo Markdown within a day. On November 16 I split each document into one file per section and committed them. On November 17 I first attached a Workflow to Coffee Shop that overwrites the same six Docs on every Push to main. This post covers that flow and what I fixed after the first run.

1. Moving the source from Google Docs to the repo

On 2026-10-17 the procedure made Google Docs the source. The repo held only the README, CONTRIBUTING and short notes, and the plan, SRS and SDD were all written in Google Docs.

The next day, 10-18, I flipped it. The source is local Markdown, and Google Docs is synced once when a stage ends or before showing it to others. The reason survives in a parenthetical in the rules file. Syncing Google Docs on every Pull request in account.stairno.com was too slow. The Google Docs connector the agent uses can only edit by specifying a position inside the document, so every edit meant reading hundreds of KB for one document. At that point the four documents sat in docs/specs/ but were not committed because of .gitignore; the reason is not recorded.

2. One file per section

In the early hours of 2026-11-16 I replaced the four uncommitted single files with committed per-section files. This is Docs as code. Two reasons:

  • Two computers: I alternate between a Windows desktop and a MacBook. If a document is not committed, one machine does not know what the other changed. Once committed, documents ride the same two-computer structure that syncs through Git.
  • How much the agent reads: with one file per document the agent reads the whole thing to see one section. With one file per section it reads the file list in docs/specs/README.md and opens only what it needs.

I also weighed security. A private repo has one account, me, so I commit as is. In a public repo I remove unfixed security holes, admin addresses, internal hosts, operating procedures and anything a client asked to keep private, and write (Google Docs only) in their place. Secrets and personal data go in no repo.

3. Choosing the sync direction

Why the sync direction was chosen: the rejected option is Google Docs first, the chosen one is automatic one-way from the repo source

Why the sync direction was chosen: the rejected option is Google Docs first, the chosen one is automatic one-way from the repo source

The same day I also considered writing in Google Docs first and moving to the repo. Looking only at syncing between Mac and Windows, it seemed natural. I rejected it for four reasons and chose One-way sync.

Reason rejectedDetail
Must read the whole thingThe agent has to read an entire Doc to see one section
Position-based APIThe Docs API edits by position (index) inside the document, slow and fragile
Breaks the PR ruleCode and the design change for that code cannot go in one Pull request
Drift only changes sidesAs long as a person copies, the two eventually drift whichever side comes first

There are three costs too. Auth setup is needed, each overwrite detaches Google Docs comment anchors, and table formatting gets simpler. So a rule came with it: people do not edit Google Docs, they only comment. I answer a comment by fixing the repo, and open comments are handled before the Merge that rebuilds that Doc.

4. What the Workflow does

From the repo to Google Docs, one way: push, GitHub Actions, OIDC and WIF, Google Doc

From the repo to Google Docs, one way: push, GitHub Actions, OIDC and WIF, Google Doc

docs-sync.yml runs when a Push to main changes any of docs/specs/, docs/images/ or .github/google-docs.json. It can also be run manually (workflow_dispatch).

  1. Render Mermaid code blocks to PNG with mmdc (mermaid-cli 11.4.2). Install fonts-noto-cjk first so Korean text does not break.
  2. Google Docs cannot show SVG, so SVGs at that commit are fetched as PNG through images.weserv.nl (possible because the repo is public).
  3. For each document folder, join the section files in the order listed in README.md into one HTML file. Only the file-list table is dropped; other tables stay. Images go in as Data URIs.
  4. Stamp the Commit hash (commit SHA) at the top, so opening a Doc shows which commit built it.
  5. Overwrite the same Doc ID with the Google Drive API PATCH /upload/drive/v3/files/<id>. No new file is created, so the share link never changes. Drive converts the text/html body into Google Docs format.

Drawing diagrams in Mermaid follows from this flow too. GitHub renders it directly, a Diff shows the change, and the Workflow can turn it into an image. I dropped draw.io SVG because a Diff does not show what changed.

The six Docs (SPMP, SRS, SDD, STP, SIP, SMP) are created first under my account, because the Service account the Workflow uses has no Drive storage quota and cannot create new Docs. The pairing of document name and Doc ID is in .github/google-docs.json. In a repo without this file, the Workflow skips the overwrite in step 5 and the authentication before it, and only keeps the built HTML as an Artifact. As of 2026-11-29 Coffee Shop is the only repo with the file; in design-system and open-calls the same Workflow only runs through the build.

5. Keyless auth

The first version put the service account's JSON key in a repo Secret. If the key leaks, Drive write access leaks with it. On 2026-11-17, the day I first attached this to Coffee Shop, I switched to WIF and deleted the key I had made. The rules record only the outcome, "never create a JSON key again", with no sentence explaining why. That day's work looks like it happened in a Mac session, so I could not find it in the Windows-side records.

It works like this. Google Cloud verifies the OIDC token that GitHub Actions issues on every run and, if the condition holds, hands out a Short-lived token for the Service account. The condition is that the repo owner is seren-wib. So any repo of mine uses the same setup, and no repo needs a Secret. The Secret count is 0.

6. Fixing images after the first run

The same day the first run updated six Google Docs. Opening them showed the images were the problem, and I fixed it with three Pull requests.

Image fitting diagram. The page body is 624 px wide and 864 px tall. A 1600 px wide PNG overflowed before #65, #65 capped only the width, and #69 fits both directions with scale = min(624/w, 864/h, 1)
PRSymptomFix
#65A 1600 px wide PNG overflowed the bodyRead the real size from the PNG header (IHDR) and write width=min(w, 624) and a proportional height in px
#66In run 44027929044, all Korean text in 15 Mermaid PNGs of the SDD became boxesInstall fonts-noto-cjk before rendering Mermaid. The 15 draw.io SVGs were fine all along
#69The tall create_order flowchart, 468×1168 pt, overflowed the 648 pt bodyCap the height at 864 px too: scale = min(624/w, 864/h, 1)

I did not use % widths in #65 because Google Docs ignores % width and max-width when importing HTML and only accepts px. So I read width and height from the IHDR chunk within the first 24 bytes of the PNG. I checked #69's math with 3 tests: 1248×400 becomes 624×200, 600×2000 becomes 259×864, and 300×100 stays as is. To reuse this script in other projects I keep the original in the dotfiles project-docs skill and a copy in the repo.

#66 and #69 changed docs-sync.yml and .github/scripts/build-docs.mjs, and both are outside the trigger paths (paths). A Merge alone did not run the Workflow again, so I ran it manually once right after each.

7. Results and limits

As of 2026-11-29. Sources: gh run list --workflow docs-sync.yml, the run logs, and wc -l on Coffee Shop's .github/ files.

ItemValue
Repos using sync1 (Coffee Shop)
Repos that only run the builddesign-system, open-calls
Coffee Shop docs-sync total runs35 (11-17 to 11-28): 33 by push (23 succeeded, 10 cancelled), 2 manual
build-docs.mjs / docs-sync.yml87 lines / 96 lines (Coffee Shop)
Local build result (#64)6 documents, 15 SDD figures (PNG), 2.0 MB of HTML
Max image size624 × 864 px
Google auth keys in repos0

The 10 cancelled runs are not failures. With concurrency: docs-sync and cancel-in-progress: true, when document Pull requests are Merged back to back, earlier runs are cut off and only the last commit is uploaded. Since it overwrites anyway, there is no reason to keep intermediate results.

Limit: the assignment submission is built separately from this Doc. It needs a cover, page breaks and keeping a figure's heading on the same page, but page-break CSS is ignored by HTML upload. The final submissions (SRS 86 pages, design specification 129 pages) were built separately from the same Markdown, with page breaks inserted through the Docs API. The synced Doc is for seeing what main says right now.

8. Reflection

Once the source was one place, the question "which side is right" disappeared.